<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.60">
    <script>
      (function() {
        const userMode = localStorage.getItem('vuepress-reco-color-scheme') || 'auto';
        const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

        if (userMode === 'dark' || (userMode === 'auto' && systemDarkMode)) {
          document.documentElement.classList.toggle('dark', true);
        }
      })();
    </script>
    <title>Easy Excel 表格库 | 阿派 | Apai Blog</title><meta name="description" content="Just playing around">
    <link rel="modulepreload" href="/assets/app-8a43a0f0.js"><link rel="modulepreload" href="/assets/framework-e1bed10d.js"><link rel="modulepreload" href="/assets/EasyExcel.html-b1eb613d.js"><link rel="modulepreload" href="/assets/EasyExcel.html-ac2c3493.js"><link rel="prefetch" href="/assets/index.html-ef2f4f01.js" as="script"><link rel="prefetch" href="/assets/index.html-1013d654.js" as="script"><link rel="prefetch" href="/assets/index.html-a146dedc.js" as="script"><link rel="prefetch" href="/assets/index.html-f4b2eaea.js" as="script"><link rel="prefetch" href="/assets/index.html-e3ed352e.js" as="script"><link rel="prefetch" href="/assets/index.html-42ce2ab9.js" as="script"><link rel="prefetch" href="/assets/index.html-ec24ec9e.js" as="script"><link rel="prefetch" href="/assets/index.html-d3d8d7ce.js" as="script"><link rel="prefetch" href="/assets/index.html-9faf073b.js" as="script"><link rel="prefetch" href="/assets/index.html-9364b7dd.js" as="script"><link rel="prefetch" href="/assets/index.html-fc0fb462.js" as="script"><link rel="prefetch" href="/assets/index.html-603c6c19.js" as="script"><link rel="prefetch" href="/assets/index.html-0349deb8.js" as="script"><link rel="prefetch" href="/assets/index.html-09405a87.js" as="script"><link rel="prefetch" href="/assets/index.html-91577c59.js" as="script"><link rel="prefetch" href="/assets/index.html-552ae255.js" as="script"><link rel="prefetch" href="/assets/index.html-424369c4.js" as="script"><link rel="prefetch" href="/assets/index.html-1dfc0069.js" as="script"><link rel="prefetch" href="/assets/index.html-ec62f595.js" as="script"><link rel="prefetch" href="/assets/index.html-4621ef22.js" as="script"><link rel="prefetch" href="/assets/index.html-e189ec13.js" as="script"><link rel="prefetch" href="/assets/index.html-b424a45b.js" as="script"><link rel="prefetch" href="/assets/index.html-623952a8.js" as="script"><link rel="prefetch" href="/assets/index.html-cedcb7c8.js" as="script"><link rel="prefetch" href="/assets/index.html-07f61d2f.js" as="script"><link rel="prefetch" href="/assets/index.html-9ef01f1e.js" as="script"><link rel="prefetch" href="/assets/index.html-dfa6d19f.js" as="script"><link rel="prefetch" href="/assets/index.html-23dd0955.js" as="script"><link rel="prefetch" href="/assets/index.html-1e7a4ff3.js" as="script"><link rel="prefetch" href="/assets/index.html-e12f154a.js" as="script"><link rel="prefetch" href="/assets/index.html-30de2d02.js" as="script"><link rel="prefetch" href="/assets/index.html-6a244983.js" as="script"><link rel="prefetch" href="/assets/index.html-8900b10e.js" as="script"><link rel="prefetch" href="/assets/index.html-b3210461.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-2db9524d.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5af383c8.js" as="script"><link rel="prefetch" href="/assets/guide.html-5aaed80e.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-82ee5401.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-9d8493a0.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-3ac28a1b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-96d10c31.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-5e497e8c.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-4a44925e.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-ae8a1843.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-c9e75b16.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-6ca97faf.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-eaabb81d.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-e2cff404.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-b608a85b.js" as="script"><link rel="prefetch" href="/assets/MySql.html-4bcdc408.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-23affe6f.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-2cc19b22.js" as="script"><link rel="prefetch" href="/assets/Redis.html-f7a014e9.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-33f5c0c4.js" as="script"><link rel="prefetch" href="/assets/Spring.html-628746d6.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-49f3c621.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-ac6df88a.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-057633f1.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-57d6fc97.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-98ad6b52.js" as="script"><link rel="prefetch" href="/assets/Linux.html-43351365.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-f1276de6.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-5cdb6370.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-486e1d26.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-47e0af0f.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-d2d2666a.js" as="script"><link rel="prefetch" href="/assets/DmShengChen.html-bb069d8e.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-eae89aa5.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-4fbb86cc.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-b976b418.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-5e3d4702.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-d0f811b3.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-bb111a21.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-994cf672.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3115afab.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-35bc6477.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-015f1806.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-a64846f4.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-f53be77f.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-19f76b9e.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-19cd8153.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-f6fa9d9e.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-11fc474d.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-30777927.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-cf566ce0.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-1f259d3b.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-78322130.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-7e3a0f69.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-0168c152.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-7a4739e8.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-f488940c.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-c07a3864.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-f0993780.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-78feb321.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-caecf367.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-add01eff.js" as="script"><link rel="prefetch" href="/assets/Docker.html-14746447.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-7dc4f8d3.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-42533685.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-143bc574.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-b713587f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-b224c5e2.js" as="script"><link rel="prefetch" href="/assets/My2306.html-94838726.js" as="script"><link rel="prefetch" href="/assets/My2307.html-df2118c4.js" as="script"><link rel="prefetch" href="/assets/My2308.html-396c79bc.js" as="script"><link rel="prefetch" href="/assets/My2309.html-1ebdc4bb.js" as="script"><link rel="prefetch" href="/assets/My2310.html-d4ffbd04.js" as="script"><link rel="prefetch" href="/assets/My2311.html-30f23133.js" as="script"><link rel="prefetch" href="/assets/My2312.html-2da62191.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-90d02bf7.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-e202f6fb.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-6d4a4703.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-9fe2887f.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-d584c181.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-16f6e650.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-307223b0.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-fa6e129f.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-22c57156.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-df146bdb.js" as="script"><link rel="prefetch" href="/assets/My2401.html-49f6440f.js" as="script"><link rel="prefetch" href="/assets/My2402.html-950d4e85.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-2007281b.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-17db8380.js" as="script"><link rel="prefetch" href="/assets/404.html-f9875e7b.js" as="script"><link rel="prefetch" href="/assets/index.html-40bced6f.js" as="script"><link rel="prefetch" href="/assets/index.html-3c78780e.js" as="script"><link rel="prefetch" href="/assets/index.html-ef51ba1b.js" as="script"><link rel="prefetch" href="/assets/index.html-bdec80a5.js" as="script"><link rel="prefetch" href="/assets/index.html-3b5427f8.js" as="script"><link rel="prefetch" href="/assets/index.html-cbd49540.js" as="script"><link rel="prefetch" href="/assets/index.html-b0b97c81.js" as="script"><link rel="prefetch" href="/assets/index.html-2793d245.js" as="script"><link rel="prefetch" href="/assets/index.html-71d9a5d9.js" as="script"><link rel="prefetch" href="/assets/index.html-4e7d77cd.js" as="script"><link rel="prefetch" href="/assets/index.html-aeace11a.js" as="script"><link rel="prefetch" href="/assets/index.html-c62ed802.js" as="script"><link rel="prefetch" href="/assets/index.html-e640d31f.js" as="script"><link rel="prefetch" href="/assets/index.html-48e1c605.js" as="script"><link rel="prefetch" href="/assets/index.html-385dcb56.js" as="script"><link rel="prefetch" href="/assets/index.html-1bb1a523.js" as="script"><link rel="prefetch" href="/assets/index.html-1ed80e8d.js" as="script"><link rel="prefetch" href="/assets/index.html-2c154a45.js" as="script"><link rel="prefetch" href="/assets/index.html-3e93d436.js" as="script"><link rel="prefetch" href="/assets/index.html-2a93e2c9.js" as="script"><link rel="prefetch" href="/assets/index.html-cff07ba3.js" as="script"><link rel="prefetch" href="/assets/index.html-7ec32a34.js" as="script"><link rel="prefetch" href="/assets/index.html-ddb40108.js" as="script"><link rel="prefetch" href="/assets/index.html-40ab6c4f.js" as="script"><link rel="prefetch" href="/assets/index.html-47e4ee8b.js" as="script"><link rel="prefetch" href="/assets/index.html-c15250e1.js" as="script"><link rel="prefetch" href="/assets/index.html-fb2ea2e4.js" as="script"><link rel="prefetch" href="/assets/index.html-d7e5408a.js" as="script"><link rel="prefetch" href="/assets/index.html-a38055d0.js" as="script"><link rel="prefetch" href="/assets/index.html-be4e50cb.js" as="script"><link rel="prefetch" href="/assets/index.html-660e4bef.js" as="script"><link rel="prefetch" href="/assets/index.html-98aa61ea.js" as="script"><link rel="prefetch" href="/assets/index.html-a6b7472f.js" as="script"><link rel="prefetch" href="/assets/index.html-ab78917a.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-f2c6c309.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5714876d.js" as="script"><link rel="prefetch" href="/assets/guide.html-9a89b22b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-f8203e0a.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-4ff9d0f3.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-e1ab7a00.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-4b735204.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-a185f330.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-c0d3a063.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-f75cbb54.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-d2fc755d.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-c51a3060.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-e5a66660.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-6e16ee98.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-1cafeb7e.js" as="script"><link rel="prefetch" href="/assets/MySql.html-5adc8c86.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-2c432c8c.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-d771200f.js" as="script"><link rel="prefetch" href="/assets/Redis.html-aa5c160a.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-ce7fc825.js" as="script"><link rel="prefetch" href="/assets/Spring.html-3d622ed7.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-6fe667f9.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-96b777da.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-fe792e2f.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7fd7be86.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-f6ef44c4.js" as="script"><link rel="prefetch" href="/assets/Linux.html-a1058183.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-bf694d87.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-1e53d902.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-ef853ef3.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-7a4bb7d5.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-20ec59d7.js" as="script"><link rel="prefetch" href="/assets/DmShengChen.html-92a2db1f.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-27823973.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-ff11bb84.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-0c745945.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-958125dd.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-ce0afe07.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-9c9fb3be.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-4e07419a.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3e716bd5.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-70835a6c.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-848bb521.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-772005d8.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-69369e84.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-37ac05d4.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-0bcb1468.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-4c377e02.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-b4248616.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-511b0f0b.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-33991c95.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-8bba14d4.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-7d12c0ef.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-d520132f.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-94d1940a.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-bf156f04.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-534cd405.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-a83407ed.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-e50eba32.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-b7cdfd68.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7c2b5253.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-1f70d8b7.js" as="script"><link rel="prefetch" href="/assets/Docker.html-51026828.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-f42be316.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-a98dc972.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-b5b7ae7c.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-ce260a3f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-8daa1c69.js" as="script"><link rel="prefetch" href="/assets/My2306.html-893e00c1.js" as="script"><link rel="prefetch" href="/assets/My2307.html-e78450ff.js" as="script"><link rel="prefetch" href="/assets/My2308.html-0e38205b.js" as="script"><link rel="prefetch" href="/assets/My2309.html-06a48ebc.js" as="script"><link rel="prefetch" href="/assets/My2310.html-59afa2c3.js" as="script"><link rel="prefetch" href="/assets/My2311.html-b634eab1.js" as="script"><link rel="prefetch" href="/assets/My2312.html-aafaa08a.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-61c8ef5d.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-26a46f60.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-e9cc0012.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-11ae0fbc.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-ce744458.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-1fa338e8.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-06ab27bc.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-b1e45d5c.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-cb5c9b25.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-c36453a2.js" as="script"><link rel="prefetch" href="/assets/My2401.html-9b16cb88.js" as="script"><link rel="prefetch" href="/assets/My2402.html-3ade37a1.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-648d7d95.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-7d486783.js" as="script"><link rel="prefetch" href="/assets/404.html-7c90b0cc.js" as="script"><link rel="prefetch" href="/assets/reco-valine-a0c1af1f.js" as="script">
    <link rel="preload" href="/assets/style-8a0f09c6.css" as="style"><link rel="stylesheet" href="/assets/style-8a0f09c6.css">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><div class="common-wrapper show-series show-catalog"><div><header class="navbar-container"><!--[--><div class="site-brand nav-item"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><div class="nav-item navbar-links-wrapper" style=""><form class="search-box" role="search"><input type="search" autocomplete="off" spellcheck="false" value><!----></form><nav class="navbar-links"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><span class="xicon-container btn-toggle-dark-mode btn--dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span><span class="xicon-container btn-toggle-menus"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><circle cx="16" cy="8" r="2" fill="currentColor"></circle><circle cx="16" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="24" r="2" fill="currentColor"></circle></svg></span></div><!--]--></header><div class="mobile-menus-container"><nav class="navbar-links mobile"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><div class="appearance"><span>Appearance</span><span class="xicon-container btn-toggle-dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span></div></div><div class="series-mask"></div><aside class="series-container"><div class="site-brand"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><!--[--><!--[--><section class="series-group series-item"><h5 class="series-heading">My Apai</h5><ul><li><!--[--><a href="/docs/Rests-docs/JavaKaiFa.html" class="link series-item" aria-label="Java 开发的工具"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java 开发的工具<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/DmShengChen.html" class="link series-item" aria-label="Java 代码生成器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java 代码生成器<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">Apai 大杂烩</h5><ul><li><!--[--><a href="/docs/Rests-docs/Vuepress.html" class="link series-item" aria-label="个人网站搭建"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->个人网站搭建<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/GitLu.html" class="link series-item" aria-label="Git 工作流"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Git 工作流<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/BatJiaoBen.html" class="link series-item" aria-label="Bat 批处理脚本"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Bat 批处理脚本<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading active">技术组</h5><ul><li><!--[--><a href="/docs/Rests-docs/ShardingJDBC.html" class="link series-item" aria-label="Spring 分库分表"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Spring 分库分表<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/Swagger.html" class="link series-item" aria-label="Swagger 接口测试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Swagger 接口测试<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html" class="router-link-active router-link-exact-active link router-link-active series-item active" aria-label="Easy Excel 表格库"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Easy Excel 表格库<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Rests-docs/JSR303.html" class="link series-item" aria-label="JSR303n 参数校验"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->JSR303n 参数校验<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">工具组</h5><ul><li><!--[--><a href="/docs/Rests-docs/MinIO.html" class="link series-item" aria-label="MinIO 对象存储"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->MinIO 对象存储<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--]--></aside><!--[--><main class="page-container"><h1 class="page-title">Easy Excel 表格库</h1><div class="page-info"><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M16 4a5 5 0 1 1-5 5a5 5 0 0 1 5-5m0-2a7 7 0 1 0 7 7a7 7 0 0 0-7-7z" fill="currentColor"></path><path d="M26 30h-2v-5a5 5 0 0 0-5-5h-6a5 5 0 0 0-5 5v5H6v-5a7 7 0 0 1 7-7h6a7 7 0 0 1 7 7z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->LuisApai<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023/08/10<!--]--></span></span><!----><!----><!----></div><div class="theme-reco-default-content"><div><h1 id="easy-excel-表格库" tabindex="-1"><a class="header-anchor" href="#easy-excel-表格库" aria-hidden="true">#</a> Easy Excel 表格库</h1><h2 id="easy-excel-基础" tabindex="-1"><a class="header-anchor" href="#easy-excel-基础" aria-hidden="true">#</a> Easy Excel 基础</h2><h3 id="easy-excel-介绍" tabindex="-1"><a class="header-anchor" href="#easy-excel-介绍" aria-hidden="true">#</a> Easy Excel 介绍</h3><ul><li><p>Easy Excel 官方文档: <a href="https://easyexcel.opensource.alibaba.com/" target="_blank" rel="noopener noreferrer">地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p></li><li><p>EasyExcel是一个基于Java的、快速、简洁、解决大文件内存溢出的Excel处理工具,</p></li><li><p>他能让你在不用考虑性能、内存的等因素的情况下，快速完成Excel的读、写等功能</p></li></ul><h3 id="easy-excel-依赖" tabindex="-1"><a class="header-anchor" href="#easy-excel-依赖" aria-hidden="true">#</a> Easy Excel 依赖</h3><ul><li>现在更新到 3.x 版本 一下笔记以3.x版本为准</li></ul><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code><span class="token comment">&lt;!--Excle 2.2.3 工具库(alibb)--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>easyexcel<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.2.3<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!--Excle 3.3.2 工具库(alibb)--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>easyexcel<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>3.3.2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="excel-注解" tabindex="-1"><a class="header-anchor" href="#excel-注解" aria-hidden="true">#</a> Excel 注解</h2><blockquote><p>详情 Excel 注解: <a href="https://blog.csdn.net/weixin_57467236/article/details/126554367" target="_blank" rel="noopener noreferrer">参考地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p></blockquote><h3 id="类注解" tabindex="-1"><a class="header-anchor" href="#类注解" aria-hidden="true">#</a> 类注解</h3><p>基础类注解</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 表头高度</span>
<span class="token annotation punctuation">@HeadRowHeight</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span> 
<span class="token comment">// 内容行高度</span>
<span class="token annotation punctuation">@ContentRowHeight</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">)</span> 
<span class="token comment">// 列宽</span>
<span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">)</span> 
<span class="token comment">// 表头样式</span>
<span class="token annotation punctuation">@HeadStyle</span><span class="token punctuation">(</span>fillForegroundColor <span class="token operator">=</span> <span class="token number">44</span><span class="token punctuation">)</span> 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="字段注解" tabindex="-1"><a class="header-anchor" href="#字段注解" aria-hidden="true">#</a> 字段注解</h3><h4 id="excelproperty-导出列" tabindex="-1"><a class="header-anchor" href="#excelproperty-导出列" aria-hidden="true">#</a> @ExcelProperty 导出列</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// @ExcelProperty: 导出该字段为一列</span>
    value<span class="token operator">:</span> 标题属性 为数组可传多个标题实现复杂头 例<span class="token operator">:</span><span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
	index<span class="token operator">:</span> 列号 导出时表格列的位置
        
<span class="token comment">// 自带的转换类</span>
<span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;字符串图片转换&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> converter <span class="token operator">=</span> <span class="token class-name">StringImageConverter</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
<span class="token keyword">private</span> <span class="token class-name">String</span> imageStr<span class="token punctuation">;</span>
   
<span class="token comment">// 示例</span>
<span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
<span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="columnwith" tabindex="-1"><a class="header-anchor" href="#columnwith" aria-hidden="true">#</a> @ColumnWith</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 设置列宽度,只有一个参数value，value的单位是字符长度，最大可以设置255个字符，因为一个excel单元格最大可以写入的字符个数就是255个字符。</span>
<span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">)</span>
<span class="token keyword">private</span> <span class="token class-name">String</span> imei<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="excelignore-忽略导出" tabindex="-1"><a class="header-anchor" href="#excelignore-忽略导出" aria-hidden="true">#</a> @ExcelIgnore 忽略导出</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// @ExcelIgnore : 导出时忽略这个字段</span>

<span class="token annotation punctuation">@ExcelIgnore</span>
<span class="token keyword">private</span> <span class="token class-name">String</span> ignore<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="datetimeformat-时间转换" tabindex="-1"><a class="header-anchor" href="#datetimeformat-时间转换" aria-hidden="true">#</a> @DateTimeFormat 时间转换</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// @DateTimeFormat : Date 时间数据类型转换</span>

<span class="token doc-comment comment">/**
* 我想写到excel 用年月日的格式 导出: 2023/8/11 16:15:45
*/</span>
<span class="token annotation punctuation">@DateTimeFormat</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy年MM月dd日HH时mm分ss秒&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="numberformat-加后缀单位" tabindex="-1"><a class="header-anchor" href="#numberformat-加后缀单位" aria-hidden="true">#</a> @NumberFormat 加后缀单位</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// @NumberFormat : Double 添加后缀单位</span>

<span class="token doc-comment comment">/**
* 我想写到excel 用百分比表示 导出: 477%
*/</span>
<span class="token annotation punctuation">@NumberFormat</span><span class="token punctuation">(</span><span class="token string">&quot;#.##%&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;数字标题&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="excel-读-导入操作" tabindex="-1"><a class="header-anchor" href="#excel-读-导入操作" aria-hidden="true">#</a> | --&gt; Excel 读/导入操作</h2><h2 id="基本导入" tabindex="-1"><a class="header-anchor" href="#基本导入" aria-hidden="true">#</a> 基本导入</h2><h3 id="简述" tabindex="-1"><a class="header-anchor" href="#简述" aria-hidden="true">#</a> 简述</h3><ul><li>基本导入参考地址: <a href="https://blog.csdn.net/SGFSFGFF/article/details/124146014" target="_blank" rel="noopener noreferrer">地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li><li>导入是根据 实体类字段 <strong>@ExcelProperty(value = &quot;出身年月日&quot;, index = 4)</strong> 的value对应的读取</li><li>导入初始行数为第二行需特别注意导入模板的标题</li></ul><h3 id="导入模板示例" tabindex="-1"><a class="header-anchor" href="#导入模板示例" aria-hidden="true">#</a> 导入模板示例</h3><table><thead><tr><th>姓名</th><th>年龄</th><th>性别</th><th>手机号</th><th>出身年月日</th></tr></thead><tbody><tr><td>小李</td><td>23</td><td>男</td><td>11245788547</td><td>2000/12/12</td></tr><tr><td>小网</td><td>24</td><td>女</td><td>13875498623</td><td>1999/12/13</td></tr><tr><td>小问</td><td>25</td><td>女</td><td>17745788549</td><td>1998/12/14</td></tr><tr><td>小破</td><td>26</td><td>男</td><td>11551788550</td><td>1997/12/15</td></tr><tr><td>小试试</td><td>27</td><td>女</td><td>17882133311</td><td>1996/12/16</td></tr><tr><td>小局</td><td>28</td><td>男</td><td>18787854552</td><td>1995/12/17</td></tr><tr><td>小委</td><td>29</td><td>女</td><td>17954588553</td><td>1994/12/18</td></tr></tbody></table><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230814154424575.png" alt="image-20230814154424575"></p><h3 id="导入代码示例" tabindex="-1"><a class="header-anchor" href="#导入代码示例" aria-hidden="true">#</a> 导入代码示例</h3><h4 id="实体类" tabindex="-1"><a class="header-anchor" href="#实体类" aria-hidden="true">#</a> 实体类</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span></span><span class="token class-name">ImportVo</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">ExcelProperty</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb<span class="token punctuation">.</span></span><span class="token class-name">CustomStringStringConverter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span> <span class="token comment">// 重写equals和hashcode方法</span>
<span class="token annotation punctuation">@NoArgsConstructor</span> <span class="token comment">// 无参构造方法</span>
<span class="token annotation punctuation">@AllArgsConstructor</span> <span class="token comment">// 全参构构造方法</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">UserMessage</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;姓名&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> name<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;年龄&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Integer</span> age<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;性别&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> sex<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;手机号&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> phone<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;出身年月日&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> birthday<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="导入监听器" tabindex="-1"><a class="header-anchor" href="#导入监听器" aria-hidden="true">#</a> 导入监听器</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb<span class="token punctuation">.</span></span><span class="token class-name">ImportGj</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>context<span class="token punctuation">.</span></span><span class="token class-name">AnalysisContext</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>read<span class="token punctuation">.</span>listener<span class="token punctuation">.</span></span><span class="token class-name">ReadListener</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">ListUtils</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>fastjson<span class="token punctuation">.</span></span><span class="token class-name">JSON</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span></span><span class="token class-name">ImportVo</span><span class="token punctuation">.</span><span class="token class-name">UserMessage</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">ExecelTestService</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span>extern<span class="token punctuation">.</span>slf4j<span class="token punctuation">.</span></span><span class="token class-name">Slf4j</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

<span class="token doc-comment comment">/**
 * 有个很重要的点 DemoDataListener 不能被spring管理，要每次读取excel都要new,然后里面用到spring可以构造方法传进去
 */</span>
<span class="token annotation punctuation">@Slf4j</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">DemoDataListener</span> <span class="token keyword">implements</span> <span class="token class-name">ReadListener</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserMessage</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>

    <span class="token doc-comment comment">/**
     * 每隔5条存储数据库，实际使用中可以100条，然后清理list ，方便内存回收
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token keyword">int</span> <span class="token constant">BATCH_COUNT</span> <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 缓存的数据用户添加 达到BATCH_COUNT，需要清理一次
     */</span>
    <span class="token keyword">private</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserMessage</span><span class="token punctuation">&gt;</span></span> cachedDataList <span class="token operator">=</span> <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayListWithExpectedSize</span><span class="token punctuation">(</span><span class="token constant">BATCH_COUNT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 业务层对象, 需要调用监听器传入, 用于调用方法保存数据
     * 假设这个是一个DAO，当然有业务逻辑这个也可以是一个service。当然如果不用存储这个对象没用。
     * 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来
     */</span>
    <span class="token keyword">private</span> <span class="token class-name">ExecelTestService</span> execelTestService<span class="token punctuation">;</span>
    <span class="token keyword">public</span> <span class="token class-name">DemoDataListener</span><span class="token punctuation">(</span><span class="token class-name">ExecelTestService</span> execelTestService<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>execelTestService <span class="token operator">=</span> execelTestService<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>


    <span class="token doc-comment comment">/**
     * 这个每一条数据解析都会来调用
     * <span class="token keyword">@param</span> <span class="token parameter">data</span> 当前解析到的数据
     * <span class="token keyword">@param</span> <span class="token parameter">context</span> 内容
     */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">invoke</span><span class="token punctuation">(</span><span class="token class-name">UserMessage</span> data<span class="token punctuation">,</span> <span class="token class-name">AnalysisContext</span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;解析到一条数据:{}&quot;</span><span class="token punctuation">,</span> <span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">toJSONString</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 将解析到的数据存储到list集合中</span>
        cachedDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 达到BATCH_COUNT了，需要去存储一次数据库，防止数据几万条数据在内存，容易OOM</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>cachedDataList<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&gt;=</span> <span class="token constant">BATCH_COUNT</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// 调用方法保存数据</span>
            <span class="token function">saveData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 存储完成清理 list</span>
            cachedDataList <span class="token operator">=</span> <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayListWithExpectedSize</span><span class="token punctuation">(</span><span class="token constant">BATCH_COUNT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 所有数据解析完成了 都会来调用
     * <span class="token keyword">@param</span> <span class="token parameter">context</span>
     */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">doAfterAllAnalysed</span><span class="token punctuation">(</span><span class="token class-name">AnalysisContext</span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 这里也要保存数据，确保最后遗留的数据也存储到数据库</span>
        <span class="token function">saveData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;所有数据解析完成！&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 加上存储数据库
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">saveData</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;{}条数据，开始存储数据库！&quot;</span><span class="token punctuation">,</span> cachedDataList<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 调用业务层的方法保存数据</span>
        execelTestService<span class="token punctuation">.</span><span class="token function">saveExecls</span><span class="token punctuation">(</span>cachedDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;存储数据库成功！&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="表现层" tabindex="-1"><a class="header-anchor" href="#表现层" aria-hidden="true">#</a> 表现层</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/importExcel&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> importExcelController <span class="token punctuation">{</span>
    
    <span class="token doc-comment comment">/**
     * 业务层对象
     */</span>
    <span class="token annotation punctuation">@Resource</span>
    <span class="token keyword">private</span> <span class="token class-name">ExecelTestService</span> execelTestService<span class="token punctuation">;</span>


    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;基础导入Excel&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/importExcel&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">importExcel</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestParam</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">)</span> <span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span><span class="token punctuation">{</span>
        <span class="token comment">// .headRowNumber(2) 设置多行头表示头有两行从第三行开始读取</span>
        <span class="token comment">// EasyExcel.read(file.getInputStream(), UserMessage.class, new DemoDataListener(execelTestService)).headRowNumber(2).sheet().doRead();</span>
        <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">UserMessage</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DemoDataListener</span><span class="token punctuation">(</span>execelTestService<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doRead</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token string">&quot;success&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="业务层" tabindex="-1"><a class="header-anchor" href="#业务层" aria-hidden="true">#</a> 业务层</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">ExecelTestService</span> <span class="token keyword">extends</span> <span class="token class-name">IService</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ExecelTest</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>
	<span class="token comment">// 导入添加</span>
    <span class="token keyword">void</span> <span class="token function">saveExecls</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserMessage</span><span class="token punctuation">&gt;</span></span> cachedDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ExecelTestServiceImpl</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ExecelTestMapper</span><span class="token punctuation">,</span> <span class="token class-name">ExecelTest</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">implements</span> <span class="token class-name">ExecelTestService</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">ExecelTestMapper</span> execelTestMapper<span class="token punctuation">;</span>
    
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">saveExecls</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserMessage</span><span class="token punctuation">&gt;</span></span> userMessageList<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;进入了service层....&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        userMessageList<span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token operator">::</span><span class="token function">println</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span><span class="token string">&quot;执行完毕....&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="导入测试结果" tabindex="-1"><a class="header-anchor" href="#导入测试结果" aria-hidden="true">#</a> 导入测试结果</h4><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230814155900165.png" alt="image-20230814155900165"></p><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230814154745757.png" alt="image-20230814154745757"></p><h2 id="一次读取全部-sheet" tabindex="-1"><a class="header-anchor" href="#一次读取全部-sheet" aria-hidden="true">#</a> 一次读取全部 Sheet</h2><h3 id="代码示例" tabindex="-1"><a class="header-anchor" href="#代码示例" aria-hidden="true">#</a> 代码示例</h3><ul><li>所需的 <strong>导入监听器和实体类 与 基本导入</strong> 一致</li><li>注意 DemoDataListener的doAfterAllAnalysed 会在每个sheet读取完毕后调用一次。然后所有sheet都会往同一个DemoDataListener里面写</li><li>会造成数据重复，需要在DemoDataListener里面做数据去重处理</li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;基础导入Excel多个sheet数据 / 一次性读取全部sheet&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/importExcelIsSheet&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">importExcelIsSheet</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestParam</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">)</span> <span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span><span class="token punctuation">{</span>
    <span class="token comment">// 一次性读取全部sheet: .headRowNumber(2) 设置多行头表示头有两行从第三行开始读取</span>
    <span class="token comment">// 1. 这里需要注意 DemoDataListener的doAfterAllAnalysed 会在每个sheet读取完毕后调用一次。然后所有sheet都会往同一个DemoDataListener里面写</span>
    <span class="token comment">// 2. 会造成数据重复，需要在DemoDataListener里面做数据去重处理</span>
    <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">UserMessage</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DemoDataListener</span><span class="token punctuation">(</span>execelTestService<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">headRowNumber</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doReadAll</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token string">&quot;success&quot;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导入模板示例-1" tabindex="-1"><a class="header-anchor" href="#导入模板示例-1" aria-hidden="true">#</a> 导入模板示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230815103146084.png" alt="image-20230815103146084"></p><h2 id="分别读取-sheet" tabindex="-1"><a class="header-anchor" href="#分别读取-sheet" aria-hidden="true">#</a> 分别读取 Sheet</h2><h3 id="代码示例-1" tabindex="-1"><a class="header-anchor" href="#代码示例-1" aria-hidden="true">#</a> 代码示例</h3><ul><li>所需的 <strong>导入监听器和实体类 与 基本导入</strong> 一致</li><li>分开读取表格的多个 Sheet 不会造成数据重复的问题</li><li>确定 Sheet 的数量可写死 或者参考流的导入写成循环</li><li>如果多个 Sheet 对应的实体类不一样 则导入监听器对应的也要重新配置</li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;基础导入Excel多个sheet数据 / 分别读取全部sheet&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/importExcelIsSheetDuoci&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">importExcelIsSheetDuoci</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestParam</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">)</span> <span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span><span class="token punctuation">{</span>
    <span class="token comment">// .sheet(0) 表示读取第一个sheet .headRowNumber(2) 设置多行头表示头有两行从第三行开始读取</span>
    <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">UserMessage</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DemoDataListener</span><span class="token punctuation">(</span>execelTestService<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">headRowNumber</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doReadSync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// .sheet(1) 表示读取第二个sheet .headRowNumber(2) 设置多行头表示头有两行从第三行开始读取</span>
    <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">UserMessage</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DemoDataListener</span><span class="token punctuation">(</span>execelTestService<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">headRowNumber</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doReadSync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token string">&quot;success&quot;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导入模板示例-2" tabindex="-1"><a class="header-anchor" href="#导入模板示例-2" aria-hidden="true">#</a> 导入模板示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230815103146084.png" alt="image-20230815103146084"></p><h2 id="以流导入多个-sheet" tabindex="-1"><a class="header-anchor" href="#以流导入多个-sheet" aria-hidden="true">#</a> 以流导入多个 Sheet</h2><h3 id="代码示例-2" tabindex="-1"><a class="header-anchor" href="#代码示例-2" aria-hidden="true">#</a> 代码示例</h3><ul><li>使用这种方式无需 监听器和实体类</li><li>不会造成数据重复的问题</li><li>表格导入单元格没有数据时会导致数据为null但不影响转化 但是在赋值需注意字段类型转换</li><li>特别注意格式的转换 读取为 {0=小网, 1=24, 2=女, 3=13875498623, 4=1999/12/13} 转换为 {0:&quot;小李&quot;,1:&quot;23&quot;,2:&quot;男&quot;,3:&quot;11245788547&quot;,4:&quot;1999/12/13&quot;}</li><li>确定 Sheet 的数量可根据参考 <strong>分别读取 Sheet</strong> 写死</li><li>如果多个 Sheet 对应的实体类不一样 不采用遍历选择写死对应不同数据</li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;以流的方式导入Excel多个sheet数据&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/importExcelIsSheetLiu&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">importExcelIsSheetLiu</span><span class="token punctuation">(</span><span class="token annotation punctuation">@RequestParam</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;file&quot;</span><span class="token punctuation">)</span> <span class="token class-name">MultipartFile</span> file<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span><span class="token punctuation">{</span>
    
    <span class="token comment">// 存储数据</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">UserMessage</span><span class="token punctuation">&gt;</span></span> userMessageList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    
    <span class="token keyword">try</span> <span class="token punctuation">{</span>
        <span class="token comment">// 分别读取全部sheet</span>
        <span class="token class-name">ExcelReader</span> reader <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ReadSheet</span><span class="token punctuation">&gt;</span></span> sheets <span class="token operator">=</span> reader<span class="token punctuation">.</span><span class="token function">excelExecutor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 遍历sheet</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> sheets<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token comment">// 依次获取sheet及它的第三行以下的数据</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> sheetList <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">read</span><span class="token punctuation">(</span>file<span class="token punctuation">.</span><span class="token function">getInputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">headRowNumber</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doReadSync</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Object</span> item <span class="token operator">:</span> sheetList<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token comment">// item: {0=小网, 1=24, 2=女, 3=13875498623, 4=1999/12/13} 表格导入单元格没有数据时会导致数据为null但不影响转化</span>
                <span class="token comment">// mapStr: {0:&quot;小李&quot;,1:&quot;23&quot;,2:&quot;男&quot;,3:&quot;11245788547&quot;,4:&quot;1999/12/13&quot;}</span>
                <span class="token class-name">String</span> mapStr <span class="token operator">=</span> item<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">replaceAll</span><span class="token punctuation">(</span><span class="token string">&quot;([^:\\{\\},]+)&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;$1\&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">&quot;=&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;:\&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// 解析字符串为 Map&lt;Integer, String&gt;</span>
                <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> resultMap <span class="token operator">=</span> <span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">parseObject</span><span class="token punctuation">(</span>mapStr<span class="token punctuation">,</span> <span class="token class-name">Map</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

                <span class="token comment">// 创建对象 存储数据</span>
                <span class="token class-name">UserMessage</span> userMessage <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">UserMessage</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessage<span class="token punctuation">.</span><span class="token function">setName</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessage<span class="token punctuation">.</span><span class="token function">setAge</span><span class="token punctuation">(</span><span class="token string">&quot;null&quot;</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token number">0</span> <span class="token operator">:</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token function">parseInt</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessage<span class="token punctuation">.</span><span class="token function">setSex</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessage<span class="token punctuation">.</span><span class="token function">setPhone</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessage<span class="token punctuation">.</span><span class="token function">setBirthday</span><span class="token punctuation">(</span>resultMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                userMessageList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>userMessage<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 保存数据</span>
        execelTestService<span class="token punctuation">.</span><span class="token function">saveExecls</span><span class="token punctuation">(</span>userMessageList<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">IOException</span> e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token string">&quot;出现异常, 导入失败&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token string">&quot;success&quot;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导入模板示例-3" tabindex="-1"><a class="header-anchor" href="#导入模板示例-3" aria-hidden="true">#</a> 导入模板示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230815103146084.png" alt="image-20230815103146084"></p><h2 id="excel-写-导出操作" tabindex="-1"><a class="header-anchor" href="#excel-写-导出操作" aria-hidden="true">#</a> | --&gt; Excel 写/导出操作</h2><blockquote><p><a href="https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write" target="_blank" rel="noopener noreferrer">写Excel<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a> : 获取数据库数据 制作成Excel表格以供导出</p></blockquote><ul><li>注解参考: <a href="https://blog.csdn.net/weixin_57467236/article/details/126554367" target="_blank" rel="noopener noreferrer">Excel 注解地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li><li>一对多拦截器: <a href="https://blog.csdn.net/qq_41057885/article/details/126411957" target="_blank" rel="noopener noreferrer">地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></li></ul><h3 id="excel-写工具类" tabindex="-1"><a class="header-anchor" href="#excel-写工具类" aria-hidden="true">#</a> Excel 写工具类</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>utils</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span></span><span class="token class-name">EasyExcel</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span></span><span class="token class-name">ExcelWriter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">CellDataTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">ImageData</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">WriteCellData</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>support<span class="token punctuation">.</span></span><span class="token class-name">ExcelTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">FileUtils</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>handler<span class="token punctuation">.</span></span><span class="token class-name">WriteHandler</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span></span><span class="token class-name">WriteSheet</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">WriteCellStyle</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">WriteFont</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HorizontalCellStyleStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">HorizontalAlignment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">IndexedColors</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">VerticalAlignment</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">javax<span class="token punctuation">.</span>servlet<span class="token punctuation">.</span>http<span class="token punctuation">.</span></span><span class="token class-name">HttpServletResponse</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">File</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">IOException</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">InputStream</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">UnsupportedEncodingException</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>net<span class="token punctuation">.</span></span><span class="token class-name">URL</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>text<span class="token punctuation">.</span></span><span class="token class-name">SimpleDateFormat</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span>concurrent<span class="token punctuation">.</span>atomic<span class="token punctuation">.</span></span><span class="token class-name">AtomicReference</span></span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">EasyExcelUtil</span> <span class="token punctuation">{</span>

    <span class="token comment">// ---------- 导出前封装预设工具类方法 ----------</span>
    <span class="token doc-comment comment">/**
     * 配置导出前的 HttpServletResponse 响应
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">collocateResponse</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">UnsupportedEncodingException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 通知浏览器以附件的形式下载处理，设置返回头要注意文件名有中文的情况</span>
        <span class="token class-name">String</span> datetime <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimpleDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;yyyyMMddHHmmss&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setContentType</span><span class="token punctuation">(</span><span class="token string">&quot;application/vnd.ms-excel&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setCharacterEncoding</span><span class="token punctuation">(</span><span class="token string">&quot;utf-8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">&quot;Content-disposition&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;attachment;filename=&quot;</span> <span class="token operator">+</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span>excelName<span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">&quot;gb2312&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;ISO8859-1&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> datetime <span class="token operator">+</span> <span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 配置导出前的 HttpServletResponse 响应/设置表头居中样式
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@return</span> ExcelWriter 表格处理对象
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> IO异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">ExcelWriter</span> <span class="token function">collocateResponseStyle</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 通知浏览器以附件的形式下载处理，设置返回头要注意文件名有中文的情况</span>
        <span class="token class-name">String</span> datetime <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SimpleDateFormat</span><span class="token punctuation">(</span><span class="token string">&quot;yyyyMMddHHmmss&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setContentType</span><span class="token punctuation">(</span><span class="token string">&quot;application/vnd.ms-excel&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setCharacterEncoding</span><span class="token punctuation">(</span><span class="token string">&quot;utf-8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">&quot;Content-disposition&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;attachment;filename=&quot;</span> <span class="token operator">+</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span>excelName<span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">&quot;gb2312&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;ISO8859-1&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> datetime <span class="token operator">+</span> <span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1 设置表头样式</span>
        <span class="token class-name">WriteCellStyle</span> headStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1.1 设置表头数据居中 / 垂直居中 / 设置字体高度（以点为单位）</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setFillForegroundColor</span><span class="token punctuation">(</span><span class="token class-name">IndexedColors</span><span class="token punctuation">.</span><span class="token constant">PALE_BLUE</span><span class="token punctuation">.</span><span class="token function">getIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">WriteFont</span> headWriteFont <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteFont</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        headWriteFont<span class="token punctuation">.</span><span class="token function">setFontHeightInPoints</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">short</span><span class="token punctuation">)</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setWriteFont</span><span class="token punctuation">(</span>headWriteFont<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 2 设置表格内容样式</span>
        <span class="token class-name">WriteCellStyle</span> bodyStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2.1 设置表格内容水平居中 / 垂直居中</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 字体大小</span>
        <span class="token class-name">WriteFont</span> contentWriteFont <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteFont</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        contentWriteFont<span class="token punctuation">.</span><span class="token function">setFontHeightInPoints</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token keyword">short</span><span class="token punctuation">)</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setWriteFont</span><span class="token punctuation">(</span>contentWriteFont<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 4 拿到表格处理对象</span>
        <span class="token keyword">return</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">needHead</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">excelType</span><span class="token punctuation">(</span><span class="token class-name">ExcelTypeEnum</span><span class="token punctuation">.</span><span class="token constant">XLSX</span><span class="token punctuation">)</span>
                <span class="token comment">// 设置单元格的风格样式</span>
                <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HorizontalCellStyleStrategy</span><span class="token punctuation">(</span>headStyle<span class="token punctuation">,</span> bodyStyle<span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token comment">// ---------- 导出封装工具类方法 ----------</span>
    <span class="token doc-comment comment">/**
     * 简单的导出 Excel 表格 默认样式
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">dataList</span> 数据集合
     * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 实体类
     * <span class="token keyword">@param</span> <span class="token parameter">sheetName</span> 多表格sheet的名称 不是导出表格文件的名称
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> dataList<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">String</span> sheetName<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 配置导出前的 HttpServletResponse 响应</span>
        <span class="token function">collocateResponse</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 导出</span>
        <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span>sheetName<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doWrite</span><span class="token punctuation">(</span>dataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 简单的导出 Excel 表格 居中样式
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">dataList</span> 数据集合
     * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 实体类
     * <span class="token keyword">@param</span> <span class="token parameter">sheetName</span> 多表格sheet的名称 不是导出表格文件的名称
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">easyDownloadStyle</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> dataList<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">String</span> sheetName<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 3 设置表格sheet样式</span>
        <span class="token class-name">WriteSheet</span> sheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>sheetName<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetNo</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 4 拿到表格处理对象</span>
        <span class="token class-name">ExcelWriter</span> writer <span class="token operator">=</span> <span class="token function">collocateResponseStyle</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 5 写入excel数据</span>
        writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>dataList<span class="token punctuation">,</span> sheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 6 关闭流</span>
        writer<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 导出 Excel 表格 居中样式 指定拦截器(可实现一对多导出)
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">dataList</span> 数据集合
     * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 实体类
     * <span class="token keyword">@param</span> <span class="token parameter">sheetName</span> 多表格sheet的名称 不是导出表格文件的名称
     * <span class="token keyword">@param</span> <span class="token parameter">t</span> 拦截器
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 拦截器泛型
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">void</span> <span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> dataList<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">String</span> sheetName<span class="token punctuation">,</span> <span class="token class-name">T</span> t<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 配置导出前的 HttpServletResponse 响应</span>
        <span class="token function">collocateResponse</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1 设置表头样式</span>
        <span class="token class-name">WriteCellStyle</span> headStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1.1 设置表头数据居中</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2 设置表格内容样式</span>
        <span class="token class-name">WriteCellStyle</span> bodyStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2.1 设置表格内容水平居中</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2.2 设置表格内容垂直居中</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 3 设置表格sheet样式</span>
        <span class="token class-name">WriteSheet</span> sheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>sheetName<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetNo</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 4 拿到表格处理对象</span>
        <span class="token class-name">ExcelWriter</span> writer <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">needHead</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">excelType</span><span class="token punctuation">(</span><span class="token class-name">ExcelTypeEnum</span><span class="token punctuation">.</span><span class="token constant">XLSX</span><span class="token punctuation">)</span>
                <span class="token comment">// 自定义拦截器</span>
                <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">WriteHandler</span><span class="token punctuation">)</span> t<span class="token punctuation">)</span>
                <span class="token comment">// 设置单元格的风格样式</span>
                <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HorizontalCellStyleStrategy</span><span class="token punctuation">(</span>headStyle<span class="token punctuation">,</span> bodyStyle<span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 5 写入excel数据</span>
        writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>dataList<span class="token punctuation">,</span> sheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 6 关闭流</span>
        writer<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 导出多个sheet表格: 每个sheet表格对应一个对象/相同对象
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">dataAndSheets</span> sheet表格名称: key (名称不能相同) 数据集合: value (数据集合的对象必须是同一个对象)
     * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 对象的字节码对象
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 泛型
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">void</span> <span class="token function">easyDownloadSheets</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> dataAndSheets<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 2. 创建 ExcelWriter 对象</span>
        <span class="token class-name">ExcelWriter</span> excelWriter <span class="token operator">=</span> <span class="token function">collocateResponseStyle</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 3. 遍历 Map</span>
        <span class="token class-name">AtomicReference</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> i <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">AtomicReference</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        dataAndSheets<span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token punctuation">(</span>k<span class="token punctuation">,</span> v<span class="token punctuation">)</span> <span class="token operator">-&gt;</span> <span class="token punctuation">{</span>
            <span class="token comment">// 4. 创建 WriteSheet 对象</span>
            <span class="token class-name">WriteSheet</span> writeSheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>i<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> k<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            i<span class="token punctuation">.</span><span class="token function">getAndSet</span><span class="token punctuation">(</span>i<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 5. 写入数据</span>
            excelWriter<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>v<span class="token punctuation">,</span> writeSheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 6. 关闭流</span>
        excelWriter<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>


    <span class="token doc-comment comment">/**
     * 导出多个sheet表格: 每个sheet表格对应一个对象/不同对象
     * 1. lsMap中的集合为空将不会导出会跳过
     * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
     * <span class="token keyword">@param</span> <span class="token parameter">lsMap</span> key: sheet表格名称 value: 数据集合
     * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span>  <span class="token function">easyDownloadSheetsNo</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> lsMap<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 2. 创建 ExcelWriter 对象</span>
        <span class="token class-name">ExcelWriter</span> excelWriter <span class="token operator">=</span>  <span class="token function">collocateResponseStyle</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 3. 遍历 lsMap 集合 key: 数据集合  value: 对象的字节码对象</span>
        <span class="token keyword">int</span> num <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token comment">// 4. 创建 WriteSheet 对象</span>
        <span class="token class-name">WriteSheet</span> writeSheet <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Map<span class="token punctuation">.</span>Entry</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> entry <span class="token operator">:</span> lsMap<span class="token punctuation">.</span><span class="token function">entrySet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">String</span> key <span class="token operator">=</span> entry<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> value <span class="token operator">=</span> entry<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>value<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token keyword">continue</span><span class="token punctuation">;</span>
            writeSheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>num<span class="token punctuation">,</span> key<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>value<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getClass</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 5. 写入数据</span>
            excelWriter<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span> writeSheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
            num<span class="token operator">++</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 6. 关闭流</span>
        excelWriter<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>


    <span class="token comment">// ---------- 导出类型转换封装工具类方法 ----------</span>
    <span class="token doc-comment comment">/**
     * 导出表格图片 (单个图片): 格式流转换
     * <span class="token keyword">@param</span> <span class="token parameter">imagePath</span> 图片路径 (本地路径) (网络路径)
     * <span class="token keyword">@param</span> <span class="token parameter">typeClazz</span> 转换的类型 (File.class, InputStream.class, byte[].class, URL.class)
     * <span class="token keyword">@return</span> 返回转换后的类型
     * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 泛型
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token class-name">T</span> <span class="token function">imageConvert</span><span class="token punctuation">(</span><span class="token class-name">String</span> imagePath<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> typeClazz<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 判断类型</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token class-name">File</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token class-name">InputStream</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">openInputStream</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 导出表格图片 (多个图片): 格式流转换, 多张图片会叠加在一个单元格中
     * <span class="token keyword">@param</span> <span class="token parameter">imagePaths</span> 图片路径 (本地路径)
     * <span class="token keyword">@param</span> <span class="token parameter">wordStr</span> 图片地下单元格对应的文字
     * <span class="token keyword">@return</span> 返回转换后的类型
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> <span class="token function">imageConvert</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> imagePaths<span class="token punctuation">,</span> <span class="token class-name">String</span> wordStr<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> writeCellData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1. 配置WriteCellData对象, 这里可以设置为 EMPTY 则代表不需要其他数据了</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setStringValue</span><span class="token punctuation">(</span>wordStr<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageData</span><span class="token punctuation">&gt;</span></span> imageDataList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ImageData</span> imageData <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
        <span class="token comment">// 2. 创建对应对象进行存储, 可以放入多个图片</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">String</span> imagePath <span class="token operator">:</span> imagePaths<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 3. 放入2进制图片-设置图片类型</span>
            imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 4. 配置图片在单元格的样式 (上/右/下/左 需要留空 这个类似于 css 的 margin) 这里实测 不能设置太大 超过单元格原始大小后 打开会提示修复。暂时未找到很好的解法。</span>
            imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 5. 赋值</span>
            imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 6. 设置图片的位置 假设 现在目标 是 覆盖 当前单元格 和当前单元格右边的单元格 / 起点相对于当前单元格为0 当然可以不写</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 7. 前面3个可以不写 下面这个需要写 也就是 结尾 需要相对当前单元格 往右移动一格 / 也就是说 这个图片会覆盖当前单元格和 后面的那一格</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> writeCellData<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>

    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="excel-请求测试" tabindex="-1"><a class="header-anchor" href="#excel-请求测试" aria-hidden="true">#</a> Excel 请求测试</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>controller</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span></span><span class="token class-name">EasyExcel</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span></span><span class="token class-name">ExcelWriter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">CellDataTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>support<span class="token punctuation">.</span></span><span class="token class-name">ExcelTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">FileUtils</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">ListUtils</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span></span><span class="token class-name">WriteSheet</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">WriteCellStyle</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">WriteFont</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HorizontalCellStyleStrategy</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb<span class="token punctuation">.</span></span><span class="token class-name">ExcelMergeCellHandler</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb<span class="token punctuation">.</span></span><span class="token class-name">TestFileUtil</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span>ex<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">ExecelTestService</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>utils<span class="token punctuation">.</span></span><span class="token class-name">EasyExcelUtil</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">Api</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiOperation</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">FillPatternType</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">HorizontalAlignment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">IndexedColors</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">VerticalAlignment</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">javax<span class="token punctuation">.</span>servlet<span class="token punctuation">.</span>http<span class="token punctuation">.</span></span><span class="token class-name">HttpServletResponse</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">File</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">IOException</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">InputStream</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>net<span class="token punctuation">.</span></span><span class="token class-name">URL</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">ArrayList</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Date</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>


<span class="token doc-comment comment">/**
 * (ExecelTest)表控制层
 *
 * <span class="token keyword">@author</span> Lu-Apai: There is no BUG in seeing light and believing light to be light AOLIGEI ...
 * <span class="token keyword">@since</span> 2023-08-09 15:43:32
 */</span>

<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;$tableInfo.comment&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/execelTest&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ExecelTestController</span> <span class="token punctuation">{</span>
    
    <span class="token doc-comment comment">/**
     * 业务层对象
     */</span>
    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">ExecelTestService</span> execelTestService<span class="token punctuation">;</span>

    <span class="token comment">// ----------- 以下是测试代码 ---------------</span>
    <span class="token doc-comment comment">/**
     * 指定列导出: @ExcelProperty(value = &quot;列名&quot;, index = 列号)
     * <span class="token keyword">@param</span> <span class="token parameter">response</span>
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
     */</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;download&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;指定列导出&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">download</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">DemoData</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DemoData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;基础导出测试&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token string">&quot;指定列导出表&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">,</span> <span class="token class-name">DemoData</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 标题指定列导出: @ExcelProperty(value = <span class="token punctuation">{</span>&quot;主标题&quot;,&quot;二级标题&quot;, &quot;字符串标题&quot;<span class="token punctuation">}</span>, index = 0)
     * 1. 多级标题: value 为数组, 需要一一对应
     * <span class="token keyword">@param</span> <span class="token parameter">response</span>
     * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
     */</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTou&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTou</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;标题指定列导出&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出表&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">,</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTouSheets&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出多个sheet同对象集合&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTouSheets</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">FuZhaTou</span> datas1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas1<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;is 牛 pisad&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas1<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas1<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">15.2999</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            data1<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> ls <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet1&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">)</span><span class="token punctuation">;</span>
        ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet2&quot;</span><span class="token punctuation">,</span> data1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadSheets</span><span class="token punctuation">(</span><span class="token string">&quot;多个sheet同对象&quot;</span><span class="token punctuation">,</span> ls<span class="token punctuation">,</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTouSheetsNo&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出多个sheet不同对象集合&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTouSheetsNo</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span> a <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">DemoData</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DemoData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串aaa&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">9.99</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            a<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> b <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串bbb&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            b<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> ls <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet1-标签aaa&quot;</span><span class="token punctuation">,</span> a<span class="token punctuation">)</span><span class="token punctuation">;</span>
        ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet2-标签bbb&quot;</span><span class="token punctuation">,</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadSheetsNo</span><span class="token punctuation">(</span><span class="token string">&quot;多个sheet不同对象测试表&quot;</span><span class="token punctuation">,</span> ls<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadChange&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出 数据转换&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadChange</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ConverterData</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ConverterData</span> nv <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ConverterData</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">8.25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ConverterData</span> nan <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ConverterData</span><span class="token punctuation">(</span><span class="token string">&quot;小卢&quot;</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">4.77</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>nv<span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>nan<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token string">&quot;数据转换&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">,</span> <span class="token class-name">ConverterData</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-转换&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadImage&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadImage</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 图片位置 本地-绝对路径</span>
        <span class="token class-name">String</span> imagePath1 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-16-48.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath2 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\4bad14d0347d48cfb774bbc4e394629c.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath3 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-17.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath4 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-47.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath6 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_14-56-46.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath7 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-30_14-51-55.png&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 网络图片</span>
        <span class="token class-name">String</span> imagePath5 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>

        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageDemoApai</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span>  <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ImageDemoApai</span> imageDemoApai <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 图片位置 本地-绝对路径</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setFile</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath1<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setInputStream</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">openInputStream</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span>imagePath3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setByteArray</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath4<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 网络图片</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setUrl</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span>imagePath5<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 3. 多个图片-需要额外放入文字-而且需要放入2个图片-第一个图片靠左-第二个靠右-而且要额外的占用他后面的单元格</span>
        <span class="token comment">// 2. 创建WriteCellData对象然后赋值到对应的对象中</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> writeCellData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setWriteCellDataFile</span><span class="token punctuation">(</span>writeCellData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 3. 配置WriteCellData对象, 这里可以设置为 EMPTY 则代表不需要其他数据了</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setStringValue</span><span class="token punctuation">(</span><span class="token string">&quot;额外的放一些文字,这里是多个图片的表格单元格...&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 4. 创建对应对象进行存储, 可以放入多个图片</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageData</span><span class="token punctuation">&gt;</span></span> imageDataList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ImageData</span> imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 5. 放入2进制图片-设置图片类型</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath6<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 6. 配置图片在单元格的样式 (上/右/下/左 需要留空 这个类似于 css 的 margin) 这里实测 不能设置太大 超过单元格原始大小后 打开会提示修复。暂时未找到很好的解法。</span>
        imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 7. 放入第二个图片 和放入第一个图片一样的操作</span>
        imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath7<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 8. 设置图片的位置 假设 现在目标 是 覆盖 当前单元格 和当前单元格右边的单元格 / 起点相对于当前单元格为0 当然可以不写</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 9. 前面3个可以不写 下面这个需要写 也就是 结尾 需要相对当前单元格 往右移动一格 / 也就是说 这个图片会覆盖当前单元格和 后面的那一格</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastColumnIndex</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 存储到list中 进行导出</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageDemoApai<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格&quot;</span><span class="token punctuation">,</span> list<span class="token punctuation">,</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-图片&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadImageUtil&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格 使用工具类&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadImageUtil</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">// 图片位置 本地-绝对路径</span>
        <span class="token class-name">String</span> imagePath1 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-16-48.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath2 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\4bad14d0347d48cfb774bbc4e394629c.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath3 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-17.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath4 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-47.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath6 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_14-56-46.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> imagePath7 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-30_14-51-55.png&quot;</span><span class="token punctuation">;</span>
        <span class="token comment">// 网络图片</span>
        <span class="token class-name">String</span> imagePath5 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>

        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageDemoApai</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span>  <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">ImageDemoApai</span> imageDemoApai <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 图片位置 本地-绝对路径</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setFile</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath1<span class="token punctuation">,</span> <span class="token class-name">File</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setInputStream</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath2<span class="token punctuation">,</span> <span class="token class-name">InputStream</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span>imagePath3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setByteArray</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath4<span class="token punctuation">,</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 网络图片</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setUrl</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath5<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> strs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        strs<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imagePath6<span class="token punctuation">)</span><span class="token punctuation">;</span>
        strs<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imagePath7<span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageDemoApai<span class="token punctuation">.</span><span class="token function">setWriteCellDataFile</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>strs<span class="token punctuation">,</span> <span class="token string">&quot;cs多个图片&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 存储到list中 进行导出</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageDemoApai<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格 使用工具类&quot;</span><span class="token punctuation">,</span> list<span class="token punctuation">,</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-图片&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/exportExcelSty&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出Excel设置单元格样式&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">exportExcelSty</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token class-name">String</span> fileName <span class="token operator">=</span> <span class="token class-name">TestFileUtil</span><span class="token punctuation">.</span><span class="token function">getPath</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;writeCellDataWrite&quot;</span> <span class="token operator">+</span> <span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">WriteCellDemoData</span> writeCellDemoData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellDemoData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 设置超链接</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> hyperlink <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token string">&quot;官方网站&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellDemoData<span class="token punctuation">.</span><span class="token function">setHyperlink</span><span class="token punctuation">(</span>hyperlink<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">HyperlinkData</span> hyperlinkData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HyperlinkData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        hyperlink<span class="token punctuation">.</span><span class="token function">setHyperlinkData</span><span class="token punctuation">(</span>hyperlinkData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        hyperlinkData<span class="token punctuation">.</span><span class="token function">setAddress</span><span class="token punctuation">(</span><span class="token string">&quot;https://github.com/alibaba/easyexcel&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        hyperlinkData<span class="token punctuation">.</span><span class="token function">setHyperlinkType</span><span class="token punctuation">(</span><span class="token class-name">HyperlinkData<span class="token punctuation">.</span>HyperlinkType</span><span class="token punctuation">.</span><span class="token constant">URL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 设置备注</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> comment <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token string">&quot;备注的单元格信息&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellDemoData<span class="token punctuation">.</span><span class="token function">setCommentData</span><span class="token punctuation">(</span>comment<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">CommentData</span> commentData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">CommentData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        comment<span class="token punctuation">.</span><span class="token function">setCommentData</span><span class="token punctuation">(</span>commentData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        commentData<span class="token punctuation">.</span><span class="token function">setAuthor</span><span class="token punctuation">(</span><span class="token string">&quot;Jiaju Zhuang&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        commentData<span class="token punctuation">.</span><span class="token function">setRichTextStringData</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">RichTextStringData</span><span class="token punctuation">(</span><span class="token string">&quot;这是一个备注&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 备注的默认大小是按照单元格的大小 这里想调整到4个单元格那么大 所以向后 向下 各额外占用了一个单元格</span>
        commentData<span class="token punctuation">.</span><span class="token function">setRelativeLastColumnIndex</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        commentData<span class="token punctuation">.</span><span class="token function">setRelativeLastRowIndex</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 设置公式</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> formula <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellDemoData<span class="token punctuation">.</span><span class="token function">setFormulaData</span><span class="token punctuation">(</span>formula<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">FormulaData</span> formulaData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FormulaData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        formula<span class="token punctuation">.</span><span class="token function">setFormulaData</span><span class="token punctuation">(</span>formulaData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 将 123456789 中的第一个数字替换成 2</span>
        <span class="token comment">// 这里只是例子 如果真的涉及到公式 能内存算好尽量内存算好 公式能不用尽量不用</span>
        formulaData<span class="token punctuation">.</span><span class="token function">setFormulaValue</span><span class="token punctuation">(</span><span class="token string">&quot;REPLACE(123456789,1,1,2)&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 设置单个单元格的样式 当然样式 很多的话 也可以用注解等方式。</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> writeCellStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token string">&quot;单元格样式&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellStyle<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellDemoData<span class="token punctuation">.</span><span class="token function">setWriteCellStyle</span><span class="token punctuation">(</span>writeCellStyle<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">WriteCellStyle</span> writeCellStyleData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellStyle<span class="token punctuation">.</span><span class="token function">setWriteCellStyle</span><span class="token punctuation">(</span>writeCellStyleData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法显示背景颜色.</span>
        writeCellStyleData<span class="token punctuation">.</span><span class="token function">setFillPatternType</span><span class="token punctuation">(</span><span class="token class-name">FillPatternType</span><span class="token punctuation">.</span><span class="token constant">SOLID_FOREGROUND</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 背景绿色</span>
        writeCellStyleData<span class="token punctuation">.</span><span class="token function">setFillForegroundColor</span><span class="token punctuation">(</span><span class="token class-name">IndexedColors</span><span class="token punctuation">.</span><span class="token constant">GREEN</span><span class="token punctuation">.</span><span class="token function">getIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 设置单个单元格多种样式</span>
        <span class="token comment">// 这里需要设置 inMomery=true 不然会导致无法展示单个单元格多种样式，所以慎用</span>
        <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> richTest <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        richTest<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">RICH_TEXT_STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellDemoData<span class="token punctuation">.</span><span class="token function">setRichText</span><span class="token punctuation">(</span>richTest<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">RichTextStringData</span> richTextStringData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RichTextStringData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        richTest<span class="token punctuation">.</span><span class="token function">setRichTextStringDataValue</span><span class="token punctuation">(</span>richTextStringData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        richTextStringData<span class="token punctuation">.</span><span class="token function">setTextString</span><span class="token punctuation">(</span><span class="token string">&quot;红色绿色默认&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 前2个字红色</span>
        <span class="token class-name">WriteFont</span> writeFont <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteFont</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeFont<span class="token punctuation">.</span><span class="token function">setColor</span><span class="token punctuation">(</span><span class="token class-name">IndexedColors</span><span class="token punctuation">.</span><span class="token constant">RED</span><span class="token punctuation">.</span><span class="token function">getIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        richTextStringData<span class="token punctuation">.</span><span class="token function">applyFont</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> writeFont<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 接下来2个字绿色</span>
        writeFont <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteFont</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeFont<span class="token punctuation">.</span><span class="token function">setColor</span><span class="token punctuation">(</span><span class="token class-name">IndexedColors</span><span class="token punctuation">.</span><span class="token constant">GREEN</span><span class="token punctuation">.</span><span class="token function">getIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        richTextStringData<span class="token punctuation">.</span><span class="token function">applyFont</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> writeFont<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">WriteCellDemoData</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>writeCellDemoData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>fileName<span class="token punctuation">,</span> <span class="token class-name">WriteCellDemoData</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">inMemory</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheet</span><span class="token punctuation">(</span><span class="token string">&quot;模板&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">doWrite</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadOneIs&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出表格 一对多格式数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadOneIs</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token comment">// 网络图片</span>
        <span class="token class-name">String</span> url1 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> url2 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503211609233.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">School</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;老刘&quot;</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s3 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小李&quot;</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s4 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;七班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小卢&quot;</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s5 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s6 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小九&quot;</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s7 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小鹅&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s4<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s5<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s6<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s7<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置需要待合并的行和列。参数1：数值数组，指定需要合并的列；参数2：数值，指定从第几行开始合并</span>
        <span class="token class-name">ExcelMergeCellHandler</span> excelMergeCellHandler <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ExcelMergeCellHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token string">&quot;学校_一对多数据表&quot;</span><span class="token punctuation">,</span> list<span class="token punctuation">,</span> <span class="token class-name">School</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-学校信息&quot;</span><span class="token punctuation">,</span> excelMergeCellHandler<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 导出基础表 居中样式</span>
        <span class="token comment">// EasyExcelUtil.easyDownloadStyle(&quot;学校_一对多数据表&quot;, list, School.class, &quot;sheet-学校信息&quot;, response);</span>
    <span class="token punctuation">}</span>


    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/exportExcelOneIs&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出Excel&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">exportExcel</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token comment">// 查询需要导出的数据</span>
        <span class="token class-name">List</span> result <span class="token operator">=</span> <span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 1设置表头样式</span>
        <span class="token class-name">WriteCellStyle</span> headStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 1.1设置表头数据居中</span>
        headStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 2设置表格内容样式</span>
        <span class="token class-name">WriteCellStyle</span> bodyStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2.1设置表格内容水平居中</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 2.2设置表格内容垂直居中</span>
        bodyStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 3设置表格sheet样式</span>
        <span class="token class-name">WriteSheet</span> sheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span><span class="token string">&quot;客户信息&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span><span class="token class-name">Customer</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetNo</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 4拿到表格处理对象</span>
        <span class="token class-name">ExcelWriter</span> writer <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">needHead</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">excelType</span><span class="token punctuation">(</span><span class="token class-name">ExcelTypeEnum</span><span class="token punctuation">.</span><span class="token constant">XLSX</span><span class="token punctuation">)</span>
                <span class="token comment">// 设置需要待合并的行和列。参数1：数值数组，指定需要合并的列；参数2：数值，指定从第几行开始合并</span>
                <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">ExcelMergeCellHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token comment">// 设置单元格的风格样式</span>
                <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HorizontalCellStyleStrategy</span><span class="token punctuation">(</span>headStyle<span class="token punctuation">,</span> bodyStyle<span class="token punctuation">)</span><span class="token punctuation">)</span>
                <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 5写入excel数据</span>
        writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> sheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 6通知浏览器以附件的形式下载处理，设置返回头要注意文件名有中文</span>
        response<span class="token punctuation">.</span><span class="token function">setHeader</span><span class="token punctuation">(</span><span class="token string">&quot;Content-disposition&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;attachment;filename=&quot;</span> <span class="token operator">+</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token string">&quot;客户信息表&quot;</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">&quot;gb2312&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;ISO8859-1&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;.xlsx&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setContentType</span><span class="token punctuation">(</span><span class="token string">&quot;multipart/form-data&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        response<span class="token punctuation">.</span><span class="token function">setCharacterEncoding</span><span class="token punctuation">(</span><span class="token string">&quot;utf-8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        writer<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 导出表格 一对多格式数据 模拟数据</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Customer</span><span class="token punctuation">&gt;</span></span> <span class="token function">getData</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Customer</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;JiangXi&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;江西电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;江西省南昌市东湖区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;12345678910&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/221733/11/14107/61280/62fde84dE467522ce/79bbd42aa93f5a83.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">58</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;JiangXi&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;江西电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;江西省南昌市东湖区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;李四&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;15848563521&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/221733/11/14107/61280/62fde84dE467522ce/79bbd42aa93f5a83.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">44</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer3 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;GuangDong&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东省广州市花都区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小明&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;15847953624&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/215924/36/19623/23344/62baa985E4df523c6/4893237860b306d6.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer4 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;GuangDong&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东省广州市天河区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小红&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;16849531548&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/189640/15/26493/35837/62baa97eE6abda209/461f91e682d0e81a.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">45</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer4<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer5 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;GuangDong&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;广东省广州市天河区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小华&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;16985632481&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/189640/15/26493/35837/62baa97eE6abda209/461f91e682d0e81a.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">24</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer5<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Customer</span> customer6 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Customer</span><span class="token punctuation">(</span><span class="token string">&quot;BeiJing&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;北京电信公司&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;北京市东城区&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;姜维&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;16598645874&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span><span class="token string">&quot;https://m.360buyimg.com/babel/jfs/t1/31481/11/16081/24873/62baa97dE6f3991d0/94ae13d66b9bbfdd.jpg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">38</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>customer6<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> data<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token class-name">String</span> gb2312 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token string">&quot;客户信息表&quot;</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">&quot;gb2312&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;ISO8859-1&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>gb2312<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="基本导出" tabindex="-1"><a class="header-anchor" href="#基本导出" aria-hidden="true">#</a> 基本导出</h2><h3 id="实体类-1" tabindex="-1"><a class="header-anchor" href="#实体类-1" aria-hidden="true">#</a> 实体类</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">DemoData</span> <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;数字标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="表现层-1" tabindex="-1"><a class="header-anchor" href="#表现层-1" aria-hidden="true">#</a> 表现层</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token doc-comment comment">/**
 * 指定列导出: @ExcelProperty(value = &quot;列名&quot;, index = 列号)
 * <span class="token keyword">@param</span> <span class="token parameter">response</span>
 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
 */</span>
<span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;download&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;指定列导出&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">download</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">DemoData</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DemoData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 多表格sheet的名称 不是导出表格文件的名称</span>
    <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;基础导出测试&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token class-name">DemoData</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出模板示例" tabindex="-1"><a class="header-anchor" href="#导出模板示例" aria-hidden="true">#</a> 导出模板示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811083802278.png" alt="image-20230811083802278"></p><h2 id="复杂头导出" tabindex="-1"><a class="header-anchor" href="#复杂头导出" aria-hidden="true">#</a> 复杂头导出</h2><h3 id="实体类及样式" tabindex="-1"><a class="header-anchor" href="#实体类及样式" aria-hidden="true">#</a> 实体类及样式</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">FuZhaTou</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;金额标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811085032704.png" alt="image-20230811085032704"></p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">FuZhaTou</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;金额标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811101825564.png" alt="image-20230811101825564"></p><h3 id="表现层-2" tabindex="-1"><a class="header-anchor" href="#表现层-2" aria-hidden="true">#</a> 表现层</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token doc-comment comment">/**
* 标题指定列导出: @ExcelProperty(value = <span class="token punctuation">{</span>&quot;主标题&quot;,&quot;二级标题&quot;, &quot;字符串标题&quot;<span class="token punctuation">}</span>, index = 0)
* 1. 多级标题: value 为数组, 需要一一对应
* <span class="token keyword">@param</span> <span class="token parameter">response</span>
* <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
*/</span>
<span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTou&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTou</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token class-name">String</span> name <span class="token operator">=</span> <span class="token string">&quot;标题指定列导出&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> name<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="导出多个sheet-同对象" tabindex="-1"><a class="header-anchor" href="#导出多个sheet-同对象" aria-hidden="true">#</a> 导出多个sheet(同对象)</h2><h3 id="注意点" tabindex="-1"><a class="header-anchor" href="#注意点" aria-hidden="true">#</a> 注意点</h3><ol><li>导出多个sheet表格: 每个sheet表格对应一个对象</li><li>sheet表格名称: key (名称不能相同) 数据集合: value (数据集合的对象必须是同一个对象)</li></ol><h3 id="代码示例-3" tabindex="-1"><a class="header-anchor" href="#代码示例-3" aria-hidden="true">#</a> 代码示例</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">FuZhaTou</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;金额标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTouSheets&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出多个sheet同对象集合&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTouSheets</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> data1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">FuZhaTou</span> datas1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas1<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;is 牛 pisad&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas1<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas1<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">15.2999</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        data1<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> ls <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet1&quot;</span><span class="token punctuation">,</span> data<span class="token punctuation">)</span><span class="token punctuation">;</span>
    ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet2&quot;</span><span class="token punctuation">,</span> data1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadSheets</span><span class="token punctuation">(</span>ls<span class="token punctuation">,</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出样式示例" tabindex="-1"><a class="header-anchor" href="#导出样式示例" aria-hidden="true">#</a> 导出样式示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811112812788.png" alt="image-20230811112812788"></p><h2 id="导出多个sheet-不同对象" tabindex="-1"><a class="header-anchor" href="#导出多个sheet-不同对象" aria-hidden="true">#</a> 导出多个sheet(不同对象)</h2><h3 id="注意点-1" tabindex="-1"><a class="header-anchor" href="#注意点-1" aria-hidden="true">#</a> 注意点</h3><ol><li>导出多个sheet表格: 每个sheet表格对应一个对象, 可以为不同的实体类对象</li><li>导出的数据集合为空将不会导出 会跳过</li></ol><h3 id="代码示例-4" tabindex="-1"><a class="header-anchor" href="#代码示例-4" aria-hidden="true">#</a> 代码示例</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">FuZhaTou</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;主标题&quot;</span><span class="token punctuation">,</span><span class="token string">&quot;二级标题一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;金额标题&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">DemoData</span> <span class="token punctuation">{</span>
    
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;字符串标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>
    
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>
    
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;数字标题&quot;</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadFuZhaTouSheetsNo&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出多个sheet不同对象集合&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadFuZhaTouSheetsNo</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span> a <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">DemoData</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">DemoData</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DemoData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串aaa&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">9.99</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        a<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">FuZhaTou</span><span class="token punctuation">&gt;</span></span> b <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">10</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">FuZhaTou</span> datas <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FuZhaTou</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span><span class="token string">&quot;字符串bbb&quot;</span> <span class="token operator">+</span> i<span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        datas<span class="token punctuation">.</span><span class="token function">setDoubleData</span><span class="token punctuation">(</span><span class="token number">0.56</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        b<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>datas<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> ls <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet1-标签aaa&quot;</span><span class="token punctuation">,</span> a<span class="token punctuation">)</span><span class="token punctuation">;</span>
    ls<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sheet2-标签bbb&quot;</span><span class="token punctuation">,</span> b<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadSheetsNo</span><span class="token punctuation">(</span>ls<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出样式示例-1" tabindex="-1"><a class="header-anchor" href="#导出样式示例-1" aria-hidden="true">#</a> 导出样式示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811151344549.png" alt="image-20230811151344549"></p><h2 id="导出自定义格式转换" tabindex="-1"><a class="header-anchor" href="#导出自定义格式转换" aria-hidden="true">#</a> 导出自定义格式转换</h2><h3 id="代码示例-5" tabindex="-1"><a class="header-anchor" href="#代码示例-5" aria-hidden="true">#</a> 代码示例</h3><blockquote><p>表现层</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadChange&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;标题指定列导出 数据转换&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadChange</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ConverterData</span><span class="token punctuation">&gt;</span></span> data <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ConverterData</span> nv <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ConverterData</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">8.25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ConverterData</span> nan <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ConverterData</span><span class="token punctuation">(</span><span class="token string">&quot;小卢&quot;</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">4.77</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>nv<span class="token punctuation">)</span><span class="token punctuation">;</span>
    data<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>nan<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token class-name">ConverterData</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-转换&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>实体类</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span>
<span class="token annotation punctuation">@NoArgsConstructor</span> <span class="token comment">// 无参构造方法</span>
<span class="token annotation punctuation">@AllArgsConstructor</span> <span class="token comment">// 全参构构造方法</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ConverterData</span> <span class="token punctuation">{</span>
    
    <span class="token doc-comment comment">/**
     * converter: 自定义转换器 名字前面加上: 自定义-name
     */</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;姓名&quot;</span><span class="token punctuation">,</span> converter <span class="token operator">=</span> <span class="token class-name">CustomStringStringConverter</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> name<span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * converter: 自定义转换器 1-男 0-女
     */</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;性别&quot;</span><span class="token punctuation">,</span> converter <span class="token operator">=</span> <span class="token class-name">SexConverter</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Integer</span> sex<span class="token punctuation">;</span>
    <span class="token doc-comment comment">/**
     * 我想写到excel 用年月日的格式
     */</span>
    <span class="token annotation punctuation">@DateTimeFormat</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy年MM月dd日HH时mm分ss秒&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token string">&quot;日期标题&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Date</span> date<span class="token punctuation">;</span>
    <span class="token doc-comment comment">/**
     * 我想写到excel 用百分比表示
     */</span>
    <span class="token annotation punctuation">@NumberFormat</span><span class="token punctuation">(</span><span class="token string">&quot;#.##%&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;数字标题&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Double</span> doubleData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>converter: 自定义转换器</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">Converter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">ReadConverterContext</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">WriteConverterContext</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">CellDataTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">WriteCellData</span></span><span class="token punctuation">;</span>

<span class="token doc-comment comment">/**
 * 自定义类型转换加载器 1-男 0-女
 * 用于将 Excel 单元格中的值转换为 Java 对象，以及将 Java 对象转换为 Excel 单元格中的值
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">SexConverter</span> <span class="token keyword">implements</span> <span class="token class-name">Converter</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>

	<span class="token doc-comment comment">/**
	 * 用于指定该转换器支持的 Java 类型:
	 * 1. 在你的例子中，你返回了 Integer.class，这表示该转换器支持将整数值转换为 Excel 单元格中的字符串，
	 * 2. 以及将 Excel 单元格中的字符串转换为整数
	 * <span class="token keyword">@return</span>
	 */</span>
	<span class="token annotation punctuation">@Override</span>
	<span class="token keyword">public</span> <span class="token class-name">Class</span> <span class="token function">supportJavaTypeKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token class-name">Integer</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token doc-comment comment">/**
	 * 用于指定该转换器支持的 Excel 数据类型:
	 * 1. 在你的例子中，你返回了 CellDataTypeEnum.STRING，这表示该转换器支持在 Excel 中使用字符串类型来表示数据
	 * <span class="token keyword">@return</span>
	 */</span>
	<span class="token annotation punctuation">@Override</span>
	<span class="token keyword">public</span> <span class="token class-name">CellDataTypeEnum</span> <span class="token function">supportExcelTypeKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
		<span class="token keyword">return</span> <span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>

	<span class="token doc-comment comment">/**
	 * 这个方法在从 Excel 读取数据时调用:
	 * 1. 用于将 Excel 单元格中的值转换为 Java 对象。在你的例子中，它将 &quot;男&quot; 转换为整数值 1，将 &quot;女&quot; 转换为整数值 0
	 * 2. context.getReadCellData().getStringValue() 获取到的是单元格的值
	 * <span class="token keyword">@return</span>
	 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">Exception</span></span>
	 */</span>
	<span class="token annotation punctuation">@Override</span>
	<span class="token keyword">public</span> <span class="token class-name">Integer</span> <span class="token function">convertToJavaData</span><span class="token punctuation">(</span><span class="token class-name">ReadConverterContext</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> context<span class="token punctuation">.</span><span class="token function">getReadCellData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getStringValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">&quot;男生&quot;</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token number">1</span> <span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

	<span class="token doc-comment comment">/**
	 * 这个方法在将数据写入 Excel 时调用:
	 * 1. 用于将 Java 对象转换为 Excel 单元格中的值。在你的例子中，它将整数值 1 转换为字符串 &quot;男&quot;，将整数值 0 转换为字符串 &quot;女&quot;
	 * 2. context.getValue() 获取到的是导出字段的值
	 * <span class="token keyword">@return</span>
	 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">Exception</span></span>
	 */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> <span class="token function">convertToExcelData</span><span class="token punctuation">(</span><span class="token class-name">WriteConverterContext</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Integer</span><span class="token punctuation">&gt;</span></span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>context<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span>context<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">?</span> <span class="token string">&quot;男生&quot;</span> <span class="token operator">:</span> <span class="token string">&quot;女生&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">Converter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">ReadConverterContext</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span></span><span class="token class-name">WriteConverterContext</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">CellDataTypeEnum</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">WriteCellData</span></span><span class="token punctuation">;</span>

<span class="token doc-comment comment">/**
 * String and string converter
 *
 * <span class="token keyword">@author</span> Jiaju Zhuang
 */</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">CustomStringStringConverter</span> <span class="token keyword">implements</span> <span class="token class-name">Converter</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> <span class="token function">supportJavaTypeKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token class-name">String</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>


    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">CellDataTypeEnum</span> <span class="token function">supportExcelTypeKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 这里读的时候会调用
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">convertToJavaData</span><span class="token punctuation">(</span><span class="token class-name">ReadConverterContext</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token string">&quot;自定义：&quot;</span> <span class="token operator">+</span> context<span class="token punctuation">.</span><span class="token function">getReadCellData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getStringValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 这里是写的时候会调用 不用管
     * <span class="token keyword">@return</span>
     */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> <span class="token function">convertToExcelData</span><span class="token punctuation">(</span><span class="token class-name">WriteConverterContext</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">System</span><span class="token punctuation">.</span>out<span class="token punctuation">.</span><span class="token function">println</span><span class="token punctuation">(</span>context<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token string">&quot;自定义：&quot;</span> <span class="token operator">+</span> context<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出表格示例" tabindex="-1"><a class="header-anchor" href="#导出表格示例" aria-hidden="true">#</a> 导出表格示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230811162259175.png" alt="image-20230811162259175"></p><h2 id="图片导出" tabindex="-1"><a class="header-anchor" href="#图片导出" aria-hidden="true">#</a> 图片导出</h2><blockquote><p>可使用本地或者网络图片进行导出 / 字段为实体类地址导出加上 转换器即可 converter = StringImageConverter.class</p></blockquote><h3 id="代码示例-6" tabindex="-1"><a class="header-anchor" href="#代码示例-6" aria-hidden="true">#</a> 代码示例</h3><h4 id="实体类-2" tabindex="-1"><a class="header-anchor" href="#实体类-2" aria-hidden="true">#</a> 实体类</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span>ex</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">ExcelProperty</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ColumnWidth</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ContentRowHeight</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>converters<span class="token punctuation">.</span>string<span class="token punctuation">.</span></span><span class="token class-name">StringImageConverter</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">WriteCellData</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token operator">*</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">File</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">InputStream</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>net<span class="token punctuation">.</span></span><span class="token class-name">URL</span></span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Getter</span>
<span class="token annotation punctuation">@Setter</span>
<span class="token annotation punctuation">@NoArgsConstructor</span> <span class="token comment">// 无参构造方法</span>
<span class="token annotation punctuation">@AllArgsConstructor</span> <span class="token comment">// 全参构构造方法</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span> <span class="token comment">// 重写equals和hashcode方法</span>
<span class="token annotation punctuation">@ContentRowHeight</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span> <span class="token comment">// 文本行高度</span>
<span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span> <span class="token comment">// 列宽度</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ImageDemoApai</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;姓名&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> name<span class="token punctuation">;</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年龄&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Integer</span> age<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;头像-File&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">File</span> file<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;大头贴-InputStream&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">3</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">InputStream</span> inputStream<span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 如果string类型 必须指定转换器，string默认转换成string
     */</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;身份证照片-String&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">4</span><span class="token punctuation">,</span> converter <span class="token operator">=</span> <span class="token class-name">StringImageConverter</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> string<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;住址照片-byte[]&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> byteArray<span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 根据url导出
     *
     * <span class="token keyword">@since</span> 2.1.1
     */</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;微信网图&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">6</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">URL</span> url<span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 根据文件导出 并设置导出的位置。
     * 多图片导出 叠加一个单元格中
     * <span class="token keyword">@since</span> 3.0.0-beta1
     */</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;个人信息表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;参考图片&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;个人图集&quot;</span><span class="token punctuation">}</span><span class="token punctuation">,</span> index <span class="token operator">=</span> <span class="token number">7</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> writeCellDataFile<span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">(</span><span class="token class-name">String</span> name<span class="token punctuation">,</span> <span class="token class-name">Integer</span> age<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> name<span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>age <span class="token operator">=</span> age<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="表现层-3" tabindex="-1"><a class="header-anchor" href="#表现层-3" aria-hidden="true">#</a> 表现层</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadImage&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadImage</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token comment">// 图片位置 本地-绝对路径</span>
    <span class="token class-name">String</span> imagePath1 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-16-48.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath2 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\4bad14d0347d48cfb774bbc4e394629c.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath3 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-17.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath4 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-47.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath6 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_14-56-46.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath7 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-30_14-51-55.png&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">// 网络图片</span>
    <span class="token class-name">String</span> imagePath5 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>

    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageDemoApai</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span>  <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ImageDemoApai</span> imageDemoApai <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 图片位置 本地-绝对路径</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setFile</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath1<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setInputStream</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">openInputStream</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span>imagePath3<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setByteArray</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath4<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 网络图片</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setUrl</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span>imagePath5<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 3. 多个图片-需要额外放入文字-而且需要放入2个图片-第一个图片靠左-第二个靠右-而且要额外的占用他后面的单元格</span>
    <span class="token comment">// 2. 创建WriteCellData对象然后赋值到对应的对象中</span>
    <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> writeCellData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setWriteCellDataFile</span><span class="token punctuation">(</span>writeCellData<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 3. 配置WriteCellData对象, 这里可以设置为 EMPTY 则代表不需要其他数据了</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setStringValue</span><span class="token punctuation">(</span><span class="token string">&quot;额外的放一些文字,这里是多个图片的表格单元格...&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 4. 创建对应对象进行存储, 可以放入多个图片</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageData</span><span class="token punctuation">&gt;</span></span> imageDataList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ImageData</span> imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 5. 放入2进制图片-设置图片类型</span>
    imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath6<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 6. 配置图片在单元格的样式 (上/右/下/左 需要留空 这个类似于 css 的 margin) 这里实测 不能设置太大 超过单元格原始大小后 打开会提示修复。暂时未找到很好的解法。</span>
    imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">40</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 7. 放入第二个图片 和放入第一个图片一样的操作</span>
    imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath7<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 8. 设置图片的位置 假设 现在目标 是 覆盖 当前单元格 和当前单元格右边的单元格 / 起点相对于当前单元格为0 当然可以不写</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 9. 前面3个可以不写 下面这个需要写 也就是 结尾 需要相对当前单元格 往右移动一格 / 也就是说 这个图片会覆盖当前单元格和 后面的那一格</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastColumnIndex</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 存储到list中 进行导出</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageDemoApai<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span>list<span class="token punctuation">,</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-图片&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadImageUtil&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出图片表格 使用工具类&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadImageUtil</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token comment">// 图片位置 本地-绝对路径</span>
    <span class="token class-name">String</span> imagePath1 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-16-48.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath2 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\4bad14d0347d48cfb774bbc4e394629c.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath3 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-17.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath4 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_09-17-47.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath6 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-25_14-56-46.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> imagePath7 <span class="token operator">=</span> <span class="token string">&quot;D:\\Apai-HKWL\\Apai-App\\Apai_wxafter\\upload\\cscscs\\2023-07-20\\Snipaste_2023-05-30_14-51-55.png&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">// 网络图片</span>
    <span class="token class-name">String</span> imagePath5 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>

    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageDemoApai</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span>  <span class="token class-name">ListUtils</span><span class="token punctuation">.</span><span class="token function">newArrayList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ImageDemoApai</span> imageDemoApai <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">(</span><span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 图片位置 本地-绝对路径</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setFile</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath1<span class="token punctuation">,</span> <span class="token class-name">File</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setInputStream</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath2<span class="token punctuation">,</span> <span class="token class-name">InputStream</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setString</span><span class="token punctuation">(</span>imagePath3<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setByteArray</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath4<span class="token punctuation">,</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 网络图片</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setUrl</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>imagePath5<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> strs <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    strs<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imagePath6<span class="token punctuation">)</span><span class="token punctuation">;</span>
    strs<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imagePath7<span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageDemoApai<span class="token punctuation">.</span><span class="token function">setWriteCellDataFile</span><span class="token punctuation">(</span><span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>strs<span class="token punctuation">,</span> <span class="token string">&quot;cs多个图片&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 存储到list中 进行导出</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageDemoApai<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownload</span><span class="token punctuation">(</span>list<span class="token punctuation">,</span> <span class="token class-name">ImageDemoApai</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-图片&quot;</span><span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="工具类方法" tabindex="-1"><a class="header-anchor" href="#工具类方法" aria-hidden="true">#</a> 工具类方法</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token doc-comment comment">/**
 * 导出表格图片 (单个图片): 格式流转换
 * <span class="token keyword">@param</span> <span class="token parameter">imagePath</span> 图片路径 (本地路径) (网络路径)
 * <span class="token keyword">@param</span> <span class="token parameter">typeClazz</span> 转换的类型 (File.class, InputStream.class, byte[].class, URL.class)
 * <span class="token keyword">@return</span> 返回转换后的类型
 * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 泛型
 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span>
 */</span>
<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token class-name">T</span> <span class="token function">imageConvert</span><span class="token punctuation">(</span><span class="token class-name">String</span> imagePath<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> typeClazz<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token comment">// 判断类型</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token class-name">File</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token class-name">InputStream</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">openInputStream</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>typeClazz <span class="token operator">==</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token class-name">T</span><span class="token punctuation">)</span> <span class="token keyword">new</span> <span class="token class-name">URL</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token doc-comment comment">/**
 * 导出表格图片 (多个图片): 格式流转换, 多张图片会叠加在一个单元格中
 * <span class="token keyword">@param</span> <span class="token parameter">imagePaths</span> 图片路径 (本地路径)
 * <span class="token keyword">@param</span> <span class="token parameter">wordStr</span> 图片地下单元格对应的文字
 * <span class="token keyword">@return</span> 返回转换后的类型
 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
 */</span>
<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> <span class="token function">imageConvert</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> imagePaths<span class="token punctuation">,</span> <span class="token class-name">String</span> wordStr<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Void</span><span class="token punctuation">&gt;</span></span> writeCellData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellData</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 1. 配置WriteCellData对象, 这里可以设置为 EMPTY 则代表不需要其他数据了</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setType</span><span class="token punctuation">(</span><span class="token class-name">CellDataTypeEnum</span><span class="token punctuation">.</span><span class="token constant">STRING</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    writeCellData<span class="token punctuation">.</span><span class="token function">setStringValue</span><span class="token punctuation">(</span>wordStr<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">ImageData</span><span class="token punctuation">&gt;</span></span> imageDataList <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">ImageData</span> imageData <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
    <span class="token comment">// 2. 创建对应对象进行存储, 可以放入多个图片</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">String</span> imagePath <span class="token operator">:</span> imagePaths<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        imageData <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ImageData</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 3. 放入2进制图片-设置图片类型</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImage</span><span class="token punctuation">(</span><span class="token class-name">FileUtils</span><span class="token punctuation">.</span><span class="token function">readFileToByteArray</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">File</span><span class="token punctuation">(</span>imagePath<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setImageType</span><span class="token punctuation">(</span><span class="token class-name">ImageData<span class="token punctuation">.</span>ImageType</span><span class="token punctuation">.</span><span class="token constant">PICTURE_TYPE_PNG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 4. 配置图片在单元格的样式 (上/右/下/左 需要留空 这个类似于 css 的 margin) 这里实测 不能设置太大 超过单元格原始大小后 打开会提示修复。暂时未找到很好的解法。</span>
        imageData<span class="token punctuation">.</span><span class="token function">setTop</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setRight</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setBottom</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        imageData<span class="token punctuation">.</span><span class="token function">setLeft</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 5. 赋值</span>
        imageDataList<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>imageData<span class="token punctuation">)</span><span class="token punctuation">;</span>
        writeCellData<span class="token punctuation">.</span><span class="token function">setImageDataList</span><span class="token punctuation">(</span>imageDataList<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 6. 设置图片的位置 假设 现在目标 是 覆盖 当前单元格 和当前单元格右边的单元格 / 起点相对于当前单元格为0 当然可以不写</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeFirstColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastRowIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 7. 前面3个可以不写 下面这个需要写 也就是 结尾 需要相对当前单元格 往右移动一格 / 也就是说 这个图片会覆盖当前单元格和 后面的那一格</span>
    imageData<span class="token punctuation">.</span><span class="token function">setRelativeLastColumnIndex</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> writeCellData<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出表格示例-1" tabindex="-1"><a class="header-anchor" href="#导出表格示例-1" aria-hidden="true">#</a> 导出表格示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230812112515292.png" alt="image-20230812112515292"></p><h2 id="复杂行-一对多导出" tabindex="-1"><a class="header-anchor" href="#复杂行-一对多导出" aria-hidden="true">#</a> 复杂行-一对多导出</h2><h3 id="简概" tabindex="-1"><a class="header-anchor" href="#简概" aria-hidden="true">#</a> 简概:</h3><ol><li>还是使用基础的导出 但是添加了Easy Excel自定义的拦截器 对指定的列进行了合并处理</li><li>图片行即使指定了合并列也无法合并 (小bug后续再看解决方法)</li><li>对于导出数据 即一个实体类 (与POI的导出是使用的树级结构需注意)</li></ol><h3 id="代码示例-7" tabindex="-1"><a class="header-anchor" href="#代码示例-7" aria-hidden="true">#</a> 代码示例</h3><h4 id="实体类代码" tabindex="-1"><a class="header-anchor" href="#实体类代码" aria-hidden="true">#</a> 实体类代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span>ex</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">ExcelProperty</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ColumnWidth</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ContentRowHeight</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HeadRowHeight</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HeadStyle</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">AllArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">EqualsAndHashCode</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">NoArgsConstructor</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>net<span class="token punctuation">.</span></span><span class="token class-name">URL</span></span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span> <span class="token comment">//lombok注解，自动生成get/set方法</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span> <span class="token comment">//lombok注解，自动生成equals和hashCode方法</span>
<span class="token annotation punctuation">@NoArgsConstructor</span> <span class="token comment">//lombok注解，自动生成无参构造方法</span>
<span class="token annotation punctuation">@AllArgsConstructor</span> <span class="token comment">//lombok注解，自动生成全参构造方法</span>

<span class="token annotation punctuation">@HeadRowHeight</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span> <span class="token comment">//表头高度</span>
<span class="token annotation punctuation">@ContentRowHeight</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">)</span> <span class="token comment">//内容行高度</span>
<span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">)</span> <span class="token comment">//列宽</span>
<span class="token annotation punctuation">@HeadStyle</span><span class="token punctuation">(</span>fillForegroundColor <span class="token operator">=</span> <span class="token number">44</span><span class="token punctuation">)</span> <span class="token comment">//表头样式</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">School</span> <span class="token punctuation">{</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolName<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校编码&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolCode<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> personName<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;班级名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> telephone<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生信息&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生姓名&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> userName<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生信息&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生年龄&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Integer</span> age<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">25</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校所在地址&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolAddress<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">25</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校预览&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">URL</span> url<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="拦截器代码" tabindex="-1"><a class="header-anchor" href="#拦截器代码" aria-hidden="true">#</a> 拦截器代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span></span><span class="token class-name">Head</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>data<span class="token punctuation">.</span></span><span class="token class-name">WriteCellData</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>handler<span class="token punctuation">.</span></span><span class="token class-name">CellWriteHandler</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>holder<span class="token punctuation">.</span></span><span class="token class-name">WriteSheetHolder</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>holder<span class="token punctuation">.</span></span><span class="token class-name">WriteTableHolder</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">AllArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">NoArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">Cell</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">CellType</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">Sheet</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">CellRangeAddress</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span></span><span class="token punctuation">;</span>

<span class="token doc-comment comment">/**
 * <span class="token keyword">@author</span> Apai-自定义合并行
 * @Description 自定义单元格合并处理Handler类
 */</span>
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@NoArgsConstructor</span>
<span class="token annotation punctuation">@AllArgsConstructor</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ExcelMergeCellHandler</span> <span class="token keyword">implements</span> <span class="token class-name">CellWriteHandler</span> <span class="token punctuation">{</span>

    <span class="token comment">// 需要合并的列，从0开始算 例如：new int[]{0, 1, 2, 3, 6, 7}</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span> mergeColIndex<span class="token punctuation">;</span>
    <span class="token comment">// 从指定的行开始合并，从0开始算 例如：0-从第一行数据列开始合并，1-从第二行数据列开始合并</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span> mergeRowIndex<span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 在单元格上的所有操作完成后调用，遍历每一个单元格，判断是否需要向上合并
     */</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">afterCellDispose</span><span class="token punctuation">(</span><span class="token class-name">WriteSheetHolder</span> writeSheetHolder<span class="token punctuation">,</span> <span class="token class-name">WriteTableHolder</span> writeTableHolder<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">WriteCellData</span><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> cellDataList<span class="token punctuation">,</span> <span class="token class-name">Cell</span> cell<span class="token punctuation">,</span> <span class="token class-name">Head</span> head<span class="token punctuation">,</span> <span class="token class-name">Integer</span> relativeRowIndex<span class="token punctuation">,</span> <span class="token class-name">Boolean</span> isHead<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 获取当前单元格行下标</span>
        <span class="token keyword">int</span> currRowIndex <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getRowIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 获取当前单元格列下标</span>
        <span class="token keyword">int</span> currColIndex <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getColumnIndex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 判断是否大于指定行下标，如果大于则判断列是否也在指定的需要的合并单元列集合中</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>currRowIndex <span class="token operator">&gt;</span> mergeRowIndex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> mergeColIndex<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>currColIndex <span class="token operator">==</span> mergeColIndex<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    <span class="token doc-comment comment">/**
                     * 获取列表数据的唯一标识。不同集合的数据即使数值相同也不合并
                     * 注意：我这里的唯一标识为客户编号（Customer.userCode），在第一列，即下标为0。大家需要结合业务逻辑来做修改
                     */</span>
                    <span class="token comment">// 获取当前单元格所在的行数据的唯一标识</span>
                    <span class="token class-name">Object</span> currCode <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getRow</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getCell</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getStringCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token comment">// 获取当前单元格的正上方的单元格所在的行数据的唯一标识</span>
                    <span class="token class-name">Object</span> preCode <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getRow</span><span class="token punctuation">(</span>currRowIndex <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getCell</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getStringCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token comment">// 判断两条数据的是否是同一集合，只有同一集合的数据才能合并单元格</span>
                    <span class="token keyword">if</span> <span class="token punctuation">(</span>preCode<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>currCode<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        <span class="token comment">// 如果都符合条件，则向上合并单元格</span>
                        <span class="token function">mergeWithPrevRow</span><span class="token punctuation">(</span>writeSheetHolder<span class="token punctuation">,</span> cell<span class="token punctuation">,</span> currRowIndex<span class="token punctuation">,</span> currColIndex<span class="token punctuation">)</span><span class="token punctuation">;</span>
                        <span class="token keyword">break</span><span class="token punctuation">;</span>
                    <span class="token punctuation">}</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token doc-comment comment">/**
     * 当前单元格向上合并
     *
     * <span class="token keyword">@param</span> <span class="token parameter">writeSheetHolder</span> 表格处理句柄
     * <span class="token keyword">@param</span> <span class="token parameter">cell</span>             当前单元格
     * <span class="token keyword">@param</span> <span class="token parameter">currRowIndex</span>     当前行
     * <span class="token keyword">@param</span> <span class="token parameter">currColIndex</span>     当前列
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">mergeWithPrevRow</span><span class="token punctuation">(</span><span class="token class-name">WriteSheetHolder</span> writeSheetHolder<span class="token punctuation">,</span> <span class="token class-name">Cell</span> cell<span class="token punctuation">,</span> <span class="token keyword">int</span> currRowIndex<span class="token punctuation">,</span> <span class="token keyword">int</span> currColIndex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 获取当前单元格数值</span>
        <span class="token class-name">Object</span> currData <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getCellTypeEnum</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token class-name">CellType</span><span class="token punctuation">.</span><span class="token constant">STRING</span> <span class="token operator">?</span> cell<span class="token punctuation">.</span><span class="token function">getStringCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">:</span> cell<span class="token punctuation">.</span><span class="token function">getNumericCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 获取当前单元格正上方的单元格对象</span>
        <span class="token class-name">Cell</span> preCell <span class="token operator">=</span> cell<span class="token punctuation">.</span><span class="token function">getSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getRow</span><span class="token punctuation">(</span>currRowIndex <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getCell</span><span class="token punctuation">(</span>currColIndex<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 获取当前单元格正上方的单元格的数值</span>
        <span class="token class-name">Object</span> preData <span class="token operator">=</span> preCell<span class="token punctuation">.</span><span class="token function">getCellTypeEnum</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token class-name">CellType</span><span class="token punctuation">.</span><span class="token constant">STRING</span> <span class="token operator">?</span> preCell<span class="token punctuation">.</span><span class="token function">getStringCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">:</span> preCell<span class="token punctuation">.</span><span class="token function">getNumericCellValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 将当前单元格数值与其正上方单元格的数值比较</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>preData<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>currData<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">Sheet</span> sheet <span class="token operator">=</span> writeSheetHolder<span class="token punctuation">.</span><span class="token function">getSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">CellRangeAddress</span><span class="token punctuation">&gt;</span></span> mergeRegions <span class="token operator">=</span> sheet<span class="token punctuation">.</span><span class="token function">getMergedRegions</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 当前单元格的正上方单元格是否是已合并单元格</span>
            <span class="token keyword">boolean</span> isMerged <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">int</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> mergeRegions<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span>isMerged<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token class-name">CellRangeAddress</span> address <span class="token operator">=</span> mergeRegions<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// 若上一个单元格已经被合并，则先移出原有的合并单元，再重新添加合并单元</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>address<span class="token punctuation">.</span><span class="token function">isInRange</span><span class="token punctuation">(</span>currRowIndex <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> currColIndex<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                    sheet<span class="token punctuation">.</span><span class="token function">removeMergedRegion</span><span class="token punctuation">(</span>i<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    address<span class="token punctuation">.</span><span class="token function">setLastRow</span><span class="token punctuation">(</span>currRowIndex<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    sheet<span class="token punctuation">.</span><span class="token function">addMergedRegion</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    isMerged <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token comment">// 若上一个单元格未被合并，则新增合并单元</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>isMerged<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token class-name">CellRangeAddress</span> cellRangeAddress <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">CellRangeAddress</span><span class="token punctuation">(</span>currRowIndex <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">,</span> currRowIndex<span class="token punctuation">,</span> currColIndex<span class="token punctuation">,</span> currColIndex<span class="token punctuation">)</span><span class="token punctuation">;</span>
                sheet<span class="token punctuation">.</span><span class="token function">addMergedRegion</span><span class="token punctuation">(</span>cellRangeAddress<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="工具类方法代码" tabindex="-1"><a class="header-anchor" href="#工具类方法代码" aria-hidden="true">#</a> 工具类方法代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token doc-comment comment">/**
 * 导出 Excel 表格 居中样式 指定拦截器(可实现一对多导出)
 * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
 * <span class="token keyword">@param</span> <span class="token parameter">dataList</span> 数据集合
 * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 实体类
 * <span class="token keyword">@param</span> <span class="token parameter">sheetName</span> 多表格sheet的名称 不是导出表格文件的名称
 * <span class="token keyword">@param</span> <span class="token parameter">t</span> 拦截器
 * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
 * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 拦截器泛型
 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
 */</span>
<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">void</span> <span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> dataList<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">String</span> sheetName<span class="token punctuation">,</span> <span class="token class-name">T</span> t<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token comment">// 配置导出前的 HttpServletResponse 响应</span>
    <span class="token function">collocateResponse</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 1 设置表头样式</span>
    <span class="token class-name">WriteCellStyle</span> headStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 1.1 设置表头数据居中</span>
    headStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2 设置表格内容样式</span>
    <span class="token class-name">WriteCellStyle</span> bodyStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2.1 设置表格内容水平居中</span>
    bodyStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2.2 设置表格内容垂直居中</span>
    bodyStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 3 设置表格sheet样式</span>
    <span class="token class-name">WriteSheet</span> sheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>sheetName<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetNo</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 4 拿到表格处理对象</span>
    <span class="token class-name">ExcelWriter</span> writer <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">needHead</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">excelType</span><span class="token punctuation">(</span><span class="token class-name">ExcelTypeEnum</span><span class="token punctuation">.</span><span class="token constant">XLSX</span><span class="token punctuation">)</span>
            <span class="token comment">// 自定义拦截器</span>
            <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">WriteHandler</span><span class="token punctuation">)</span> t<span class="token punctuation">)</span>
            <span class="token comment">// 设置单元格的风格样式</span>
            <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HorizontalCellStyleStrategy</span><span class="token punctuation">(</span>headStyle<span class="token punctuation">,</span> bodyStyle<span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 5 写入excel数据</span>
    writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>dataList<span class="token punctuation">,</span> sheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 6 关闭流</span>
    writer<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="表现层代码" tabindex="-1"><a class="header-anchor" href="#表现层代码" aria-hidden="true">#</a> 表现层代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadOneIs&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出表格 一对多格式数据&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadOneIs</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
    <span class="token comment">// 网络图片</span>
    <span class="token class-name">String</span> url1 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> url2 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503211609233.png&quot;</span><span class="token punctuation">;</span>
    <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">School</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;老刘&quot;</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s3 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小李&quot;</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s4 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;七班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小卢&quot;</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s5 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s6 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小九&quot;</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">School</span> s7 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小鹅&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s2<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s3<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s4<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s5<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s6<span class="token punctuation">)</span><span class="token punctuation">;</span>
    list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s7<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 设置需要待合并的行和列。参数1：数值数组，指定需要合并的列；参数2：数值，指定从第几行开始合并</span>
    <span class="token class-name">ExcelMergeCellHandler</span> excelMergeCellHandler <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ExcelMergeCellHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token string">&quot;学校_一对多数据表&quot;</span><span class="token punctuation">,</span> list<span class="token punctuation">,</span> <span class="token class-name">School</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-学校信息&quot;</span><span class="token punctuation">,</span> excelMergeCellHandler<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// 导出基础表 居中样式</span>
    <span class="token comment">// EasyExcelUtil.easyDownloadStyle(&quot;学校_一对多数据表&quot;, list, School.class, &quot;sheet-学校信息&quot;, response);</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出表格示例-2" tabindex="-1"><a class="header-anchor" href="#导出表格示例-2" aria-hidden="true">#</a> 导出表格示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230814102948398.png" alt="image-20230814102948398"></p><h2 id="设置冻结筛选头" tabindex="-1"><a class="header-anchor" href="#设置冻结筛选头" aria-hidden="true">#</a> 设置冻结筛选头</h2><h3 id="简概-1" tabindex="-1"><a class="header-anchor" href="#简概-1" aria-hidden="true">#</a> 简概:</h3><ol><li>还是使用基础的导出 但是添加了Easy Excel自定义的拦截器 设置冻结筛选头</li><li>参考上方 一对多</li></ol><h3 id="代码示例-8" tabindex="-1"><a class="header-anchor" href="#代码示例-8" aria-hidden="true">#</a> 代码示例</h3><h4 id="实体类代码-1" tabindex="-1"><a class="header-anchor" href="#实体类代码-1" aria-hidden="true">#</a> 实体类代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>entity<span class="token punctuation">.</span>ex</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">ExcelProperty</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ColumnWidth</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">ContentRowHeight</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HeadRowHeight</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span>write<span class="token punctuation">.</span>style<span class="token punctuation">.</span></span><span class="token class-name">HeadStyle</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">AllArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">EqualsAndHashCode</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">NoArgsConstructor</span></span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">java<span class="token punctuation">.</span>net<span class="token punctuation">.</span></span><span class="token class-name">URL</span></span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span> <span class="token comment">//lombok注解，自动生成get/set方法</span>
<span class="token annotation punctuation">@EqualsAndHashCode</span> <span class="token comment">//lombok注解，自动生成equals和hashCode方法</span>
<span class="token annotation punctuation">@NoArgsConstructor</span> <span class="token comment">//lombok注解，自动生成无参构造方法</span>
<span class="token annotation punctuation">@AllArgsConstructor</span> <span class="token comment">//lombok注解，自动生成全参构造方法</span>

<span class="token annotation punctuation">@HeadRowHeight</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span> <span class="token comment">//表头高度</span>
<span class="token annotation punctuation">@ContentRowHeight</span><span class="token punctuation">(</span><span class="token number">80</span><span class="token punctuation">)</span> <span class="token comment">//内容行高度</span>
<span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">15</span><span class="token punctuation">)</span> <span class="token comment">//列宽</span>
<span class="token annotation punctuation">@HeadStyle</span><span class="token punctuation">(</span>fillForegroundColor <span class="token operator">=</span> <span class="token number">44</span><span class="token punctuation">)</span> <span class="token comment">//表头样式</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">School</span> <span class="token punctuation">{</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolName<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校编码&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolCode<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> personName<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;班级名称&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> telephone<span class="token punctuation">;</span>
 
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生信息&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生姓名&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> userName<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生信息&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学生年龄&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Integer</span> age<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">25</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校所在地址&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> schoolAddress<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ColumnWidth</span><span class="token punctuation">(</span><span class="token number">25</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ExcelProperty</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token string">&quot;通城县学校表&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;学校预览&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">URL</span> url<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="拦截器代码-1" tabindex="-1"><a class="header-anchor" href="#拦截器代码-1" aria-hidden="true">#</a> 拦截器代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>apai<span class="token punctuation">.</span>alibb</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>handler<span class="token punctuation">.</span></span><span class="token class-name">SheetWriteHandler</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>holder<span class="token punctuation">.</span></span><span class="token class-name">WriteSheetHolder</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>excel<span class="token punctuation">.</span>write<span class="token punctuation">.</span>metadata<span class="token punctuation">.</span>holder<span class="token punctuation">.</span></span><span class="token class-name">WriteWorkbookHolder</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">AllArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">NoArgsConstructor</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>usermodel<span class="token punctuation">.</span></span><span class="token class-name">Sheet</span></span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token import"><span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>poi<span class="token punctuation">.</span>ss<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">CellRangeAddress</span></span><span class="token punctuation">;</span>


<span class="token doc-comment comment">/**
 * <span class="token keyword">@author</span> Apai-自定义拦截器
 * @Description 将指定的标题行冻结，指定的标题行以下的数据进行筛选
 */</span>
<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@NoArgsConstructor</span>
<span class="token annotation punctuation">@AllArgsConstructor</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">FreezeAndFilter</span> <span class="token keyword">implements</span> <span class="token class-name">SheetWriteHandler</span> <span class="token punctuation">{</span>

    <span class="token doc-comment comment">/**
     * 水平拆分位置
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span> colSplit <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 拆分的垂直位置
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span> rowSplit <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 右窗格中可见的左列
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span> leftmostColumn <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 底部窗格中可见的顶行
     */</span>
    <span class="token keyword">private</span> <span class="token keyword">int</span> topRow <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 设置筛选范围
     * （参数A2：D2代表从第二行第A列到第二行第J列要作为筛选框的位置）
     */</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> autoFilterRange <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>

    <span class="token doc-comment comment">/**
     * 设置冻结和筛选
     * <span class="token keyword">@param</span> <span class="token parameter">rowSplit</span> 冻结行数 例如: 2 表示前两行冻结
     * <span class="token keyword">@param</span> <span class="token parameter">autoFilterRange</span> 筛选范围 例如: A2:D2
     */</span>
    <span class="token keyword">public</span> <span class="token class-name">FreezeAndFilter</span><span class="token punctuation">(</span><span class="token keyword">int</span> rowSplit<span class="token punctuation">,</span> <span class="token class-name">String</span> autoFilterRange<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>rowSplit <span class="token operator">=</span> rowSplit<span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>autoFilterRange <span class="token operator">=</span> autoFilterRange<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">beforeSheetCreate</span><span class="token punctuation">(</span><span class="token class-name">WriteWorkbookHolder</span> writeWorkbookHolder<span class="token punctuation">,</span> <span class="token class-name">WriteSheetHolder</span> writeSheetHolder<span class="token punctuation">)</span> <span class="token punctuation">{</span>

    <span class="token punctuation">}</span>

    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">afterSheetCreate</span><span class="token punctuation">(</span><span class="token class-name">WriteWorkbookHolder</span> writeWorkbookHolder<span class="token punctuation">,</span> <span class="token class-name">WriteSheetHolder</span> writeSheetHolder<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Sheet</span> sheet <span class="token operator">=</span> writeSheetHolder<span class="token punctuation">.</span><span class="token function">getSheet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置冻结</span>
        sheet<span class="token punctuation">.</span><span class="token function">createFreezePane</span><span class="token punctuation">(</span>colSplit<span class="token punctuation">,</span> rowSplit<span class="token punctuation">,</span> leftmostColumn<span class="token punctuation">,</span> topRow<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置筛选</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>autoFilterRange <span class="token operator">!=</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            sheet<span class="token punctuation">.</span><span class="token function">setAutoFilter</span><span class="token punctuation">(</span><span class="token class-name">CellRangeAddress</span><span class="token punctuation">.</span><span class="token function">valueOf</span><span class="token punctuation">(</span>autoFilterRange<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 设置冻结和筛选 A2：D2代表从第二行第A列到第二行第J列要作为筛选框的位置</span>
        <span class="token comment">// sheet.setAutoFilter(new CellRangeAddress(1,1,0,3));</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="工具类方法代码-1" tabindex="-1"><a class="header-anchor" href="#工具类方法代码-1" aria-hidden="true">#</a> 工具类方法代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token doc-comment comment">/**
 * 导出 Excel 表格 居中样式 指定拦截器(可实现一对多导出)
 * <span class="token keyword">@param</span> <span class="token parameter">excelName</span> 导出表格的名称
 * <span class="token keyword">@param</span> <span class="token parameter">dataList</span> 数据集合
 * <span class="token keyword">@param</span> <span class="token parameter">entityClass</span> 实体类
 * <span class="token keyword">@param</span> <span class="token parameter">sheetName</span> 多表格sheet的名称 不是导出表格文件的名称
 * <span class="token keyword">@param</span> <span class="token parameter">t</span> 拦截器
 * <span class="token keyword">@param</span> <span class="token parameter">response</span> 前端请求返回的响应
 * <span class="token keyword">@param</span> <span class="token class-name"><span class="token punctuation">&lt;</span>T<span class="token punctuation">&gt;</span></span> 拦截器泛型
 * <span class="token keyword">@throws</span> <span class="token reference"><span class="token class-name">IOException</span></span> 抛出异常
 */</span>
<span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">T</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">void</span> <span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token class-name">String</span> excelName<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> dataList<span class="token punctuation">,</span> <span class="token class-name">Class</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token operator">?</span><span class="token punctuation">&gt;</span></span> entityClass<span class="token punctuation">,</span> <span class="token class-name">String</span> sheetName<span class="token punctuation">,</span> <span class="token class-name">T</span> t<span class="token punctuation">,</span> <span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
    <span class="token comment">// 配置导出前的 HttpServletResponse 响应</span>
    <span class="token function">collocateResponse</span><span class="token punctuation">(</span>excelName<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 1 设置表头样式</span>
    <span class="token class-name">WriteCellStyle</span> headStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 1.1 设置表头数据居中</span>
    headStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2 设置表格内容样式</span>
    <span class="token class-name">WriteCellStyle</span> bodyStyle <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">WriteCellStyle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2.1 设置表格内容水平居中</span>
    bodyStyle<span class="token punctuation">.</span><span class="token function">setHorizontalAlignment</span><span class="token punctuation">(</span><span class="token class-name">HorizontalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 2.2 设置表格内容垂直居中</span>
    bodyStyle<span class="token punctuation">.</span><span class="token function">setVerticalAlignment</span><span class="token punctuation">(</span><span class="token class-name">VerticalAlignment</span><span class="token punctuation">.</span><span class="token constant">CENTER</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 3 设置表格sheet样式</span>
    <span class="token class-name">WriteSheet</span> sheet <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">writerSheet</span><span class="token punctuation">(</span>sheetName<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">head</span><span class="token punctuation">(</span>entityClass<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sheetNo</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 4 拿到表格处理对象</span>
    <span class="token class-name">ExcelWriter</span> writer <span class="token operator">=</span> <span class="token class-name">EasyExcel</span><span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>response<span class="token punctuation">.</span><span class="token function">getOutputStream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">needHead</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">excelType</span><span class="token punctuation">(</span><span class="token class-name">ExcelTypeEnum</span><span class="token punctuation">.</span><span class="token constant">XLSX</span><span class="token punctuation">)</span>
            <span class="token comment">// 自定义拦截器</span>
            <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token class-name">WriteHandler</span><span class="token punctuation">)</span> t<span class="token punctuation">)</span>
            <span class="token comment">// 设置单元格的风格样式</span>
            <span class="token punctuation">.</span><span class="token function">registerWriteHandler</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">HorizontalCellStyleStrategy</span><span class="token punctuation">(</span>headStyle<span class="token punctuation">,</span> bodyStyle<span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">.</span><span class="token function">build</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 5 写入excel数据</span>
    writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>dataList<span class="token punctuation">,</span> sheet<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 6 关闭流</span>
    writer<span class="token punctuation">.</span><span class="token function">finish</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="表现层代码-1" tabindex="-1"><a class="header-anchor" href="#表现层代码-1" aria-hidden="true">#</a> 表现层代码</h4><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;downloadOneIs&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span><span class="token string">&quot;导出表格 一对多格式数据&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">downloadOneIs</span><span class="token punctuation">(</span><span class="token class-name">HttpServletResponse</span> response<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">{</span>
        <span class="token comment">// 网络图片</span>
        <span class="token class-name">String</span> url1 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503204942958.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> url2 <span class="token operator">=</span> <span class="token string">&quot;https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20230503211609233.png&quot;</span><span class="token punctuation">;</span>
        <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">School</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;张三&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;老刘&quot;</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s3 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小李&quot;</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s4 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;七班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小卢&quot;</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s5 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;城关小学&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;CG-47725&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;二年级&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小王&quot;</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token string">&quot;海鼎卢25号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url1<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s6 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小九&quot;</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">School</span> s7 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">School</span><span class="token punctuation">(</span><span class="token string">&quot;建水初中&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;JS-78425&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;初一&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;一班&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;小鹅&quot;</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token string">&quot;建水路网金街道27号&quot;</span><span class="token punctuation">,</span> <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">imageConvert</span><span class="token punctuation">(</span>url2<span class="token punctuation">,</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s2<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s3<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s4<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s5<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s6<span class="token punctuation">)</span><span class="token punctuation">;</span>
        list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>s7<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 设置需要待合并的行和列。参数1：数值数组，指定需要合并的列；参数2：数值，指定从第几行开始合并</span>
<span class="token comment">//        ExcelMergeCellHandler excelMergeCellHandler = new ExcelMergeCellHandler(new int[]{0, 1, 2, 3, 6, 7}, 0);</span>
<span class="token comment">//        EasyExcelUtil.easyDownloadBlocker(&quot;学校_一对多数据表&quot;, list, School.class, &quot;sheet-学校信息&quot;, excelMergeCellHandler, response);</span>
        <span class="token comment">// 冻结筛选表头</span>
        <span class="token class-name">FreezeAndFilter</span> freezeAndFilter <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">FreezeAndFilter</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span> <span class="token string">&quot;A3:H3&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">EasyExcelUtil</span><span class="token punctuation">.</span><span class="token function">easyDownloadBlocker</span><span class="token punctuation">(</span><span class="token string">&quot;学校_一对多数据表&quot;</span><span class="token punctuation">,</span> list<span class="token punctuation">,</span> <span class="token class-name">School</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> <span class="token string">&quot;sheet-学校信息&quot;</span><span class="token punctuation">,</span> freezeAndFilter<span class="token punctuation">,</span> response<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">// 导出基础表 居中样式</span>
        <span class="token comment">// EasyExcelUtil.easyDownloadStyle(&quot;学校_一对多数据表&quot;, list, School.class, &quot;sheet-学校信息&quot;, response);</span>
    <span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="导出表格示例-3" tabindex="-1"><a class="header-anchor" href="#导出表格示例-3" aria-hidden="true">#</a> 导出表格示例</h3><p><img src="https://cdn.jsdelivr.net/gh/LuJunandapai/ApaiImage@main/MaYun-PicGo/image-20230814144330527.png" alt="image-20230814144330527"></p></div></div><footer class="page-meta"><!----><div class="meta-item last-updated"><span class="xicon-container left meta-item-label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Last Updated 2023-08-15 06:45:43<!--]--></span></span></div></footer><nav class="page-nav"><p class="hasPrev hasNext inner"><span class="page-nav-item prev"> ← Swagger 接口测试</span><span class="page-nav-item next">JSR303n 参数校验 → </span></p></nav><!----></main><!--]--><div class="page-catalog-container"><h5 class="tip">文章层级目录</h5><ul><!--[--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#easy-excel-基础" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Easy Excel 基础"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Easy Excel 基础<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#easy-excel-介绍" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Easy Excel 介绍"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Easy Excel 介绍<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#easy-excel-依赖" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Easy Excel 依赖"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Easy Excel 依赖<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#excel-注解" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Excel 注解"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Excel 注解<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#类注解" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="类注解"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->类注解<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#字段注解" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="字段注解"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->字段注解<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#excel-读-导入操作" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="| --&gt; Excel 读/导入操作"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->| --&gt; Excel 读/导入操作<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#基本导入" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="基本导入"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->基本导入<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#简述" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="简述"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->简述<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导入模板示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导入模板示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导入模板示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导入代码示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导入代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导入代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#一次读取全部-sheet" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="一次读取全部 Sheet"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->一次读取全部 Sheet<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导入模板示例-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导入模板示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导入模板示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#分别读取-sheet" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="分别读取 Sheet"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分别读取 Sheet<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导入模板示例-2" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导入模板示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导入模板示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#以流导入多个-sheet" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="以流导入多个 Sheet"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->以流导入多个 Sheet<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-2" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导入模板示例-3" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导入模板示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导入模板示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#excel-写-导出操作" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="| --&gt; Excel 写/导出操作"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->| --&gt; Excel 写/导出操作<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#excel-写工具类" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Excel 写工具类"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Excel 写工具类<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#excel-请求测试" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Excel 请求测试"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Excel 请求测试<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#基本导出" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="基本导出"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->基本导出<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#实体类-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="实体类"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->实体类<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#表现层-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="表现层"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->表现层<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出模板示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出模板示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出模板示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#复杂头导出" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="复杂头导出"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->复杂头导出<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#实体类及样式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="实体类及样式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->实体类及样式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#表现层-2" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="表现层"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->表现层<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出多个sheet-同对象" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出多个sheet(同对象)"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出多个sheet(同对象)<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#注意点" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="注意点"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->注意点<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-3" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出样式示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出样式示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出样式示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出多个sheet-不同对象" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出多个sheet(不同对象)"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出多个sheet(不同对象)<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#注意点-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="注意点"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->注意点<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-4" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出样式示例-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出样式示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出样式示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出自定义格式转换" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出自定义格式转换"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出自定义格式转换<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-5" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出表格示例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出表格示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出表格示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#图片导出" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="图片导出"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->图片导出<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-6" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出表格示例-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出表格示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出表格示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#复杂行-一对多导出" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="复杂行-一对多导出"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->复杂行-一对多导出<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#简概" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="简概:"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->简概:<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-7" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出表格示例-2" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出表格示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出表格示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#设置冻结筛选头" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="设置冻结筛选头"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->设置冻结筛选头<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#简概-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="简概:"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->简概:<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#代码示例-8" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="代码示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->代码示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Rests-docs/EasyExcel.html#导出表格示例-3" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="导出表格示例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->导出表格示例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--]--></ul></div></div></div></div><!----><!----><!--]--></div>
    <script type="module" src="/assets/app-8a43a0f0.js" defer></script>
  </body>
</html>
